I\'ve been using Visual Basic for quite a while and have recently made the decision to begin learning C# as a step forward into learning more complex languages.
As a
I don't think you can specify a property only accessible with indexing, but you could just return an indexable value (like an array or List
) and use []
on the result:
public List Aproperty
{
get
{
return this.theList;
}
}
Aclass foo = this.Apropety[0];
Of course, anything with an indexer will work instead of List
.
Or, you could do it the other way around: define an indexer (on the class itself) that returns an object that has a property Aproperty
, used like so: Aclass foo = this[0].Aproperty
.