Link to home
Start Free TrialLog in
Avatar of john_schaffner
john_schaffner

asked on

how do you right the 'get' and 'set' accessors for an array property

So I'm trying to use a instance variable that is an array. I want to write a property that will access this private instance variable. I can't find the syntax to do this.
ASKER CERTIFIED SOLUTION
Avatar of Ravi Singh
Ravi Singh
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If your defining a collection class then you could also make use of an indexer, which would allow users of your class to use the [] operator on a reference (just like using a standard array):

e.g.

MyClass myClass = new MyClass();
string someData = myClass[0];

See: http://www.developer.com/net/csharp/article.php/1547581