tags:

views:

52

answers:

3

This is a very basic question.

void Output(int output); -> this enables one single output

bool[] Outputs { get; set; } -> This enables multiple output. I need the implementation of this. This is an API declared as a interface.

In my class I need to use it.

i studied this http://msdn.microsoft.com/en-us/library/87d83y5b%28VS.80%29.aspx... but no where I got reference to get and set returning a bool array.

In the above link, the class is as:

interface IPoint { // Property signatures: int x { get; set; } int y { get; set; } }

class Point : IPoint
{
   // Fields:
   private int _x;
   private int _y;

   // Constructor:
   public Point(int x, int y)
   {
      _x = x;
      _y = y;
   }

   // Property implementation:
   public int x
   {
      get
      {
         return _x;
      }    
      set
      {
         _x = value;
      }
   }

   public int y
   {
      get
      {
         return _y;
      }
      set
      {
         _y = value;
      }
   }
}

what will be the class declaration in my case ??

+1  A: 

It's the same as the sample on MSDN, but replace "int" with "bool[]".

Tim Robinson
+1  A: 

Here's a sample implementation:

public class YourAPIImpl: IYourAPI
{
    public bool[] Outputs { get; set; }

    public void Output(int output)
    {
        throw new NotImplementedException();
    }
}
Darin Dimitrov
+1  A: 
public bool[] Outputs {get; set;} 

will create a property named "Outputs" returning bool array. This is a shortcut syntax, if you wish to use longer syntax then it would go some thing like

private bool[] _outputs;
public bool[] Outputs
{
   get
    {
      return _outputs;
    }
   set
    {
      _outputs = value;
    }
}
VinayC
Thanks for the reply Vinay. public interface myInterface{ bool[] Outputs { get; set; } void Output(int output);}class myClass : Form -> here i need to use that myInterface. But myClass inherits Form. So what will be the case here ? ?
SLp
You can inherit from one class and multiple interfaces. So just add command and the interface name after form. ( myClass:Form, IMyInterface)
VinayC