开发者

get set property as a bool[] return

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
      {
 开发者_如何学C        return _x;
      }    
      set
      {
         _x = value;
      }
   }

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

what will be the class declaration in my case ??


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;
    }
}


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


Here's a sample implementation:

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

    public void Output(int output)
    {
        throw new NotImplementedException();
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜