SLp
SLp

Reputation: 135

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
      {
         return _x;
      }    
      set
      {
         _x = value;
      }
   }

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

what will be the class declaration in my case ??

Upvotes: 0

Views: 12841

Answers (3)

VinayC
VinayC

Reputation: 49195

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

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1038820

Here's a sample implementation:

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

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

Upvotes: 1

Tim Robinson
Tim Robinson

Reputation: 54734

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

Upvotes: 1

Related Questions