Indexers
Last updated
Was this helpful?
Last updated
Was this helpful?
Indexers enable objects to be indexed in a similar manner to arrays.
A get
accessor returns a value. A set
accessor assigns a value.
The keyword is used to define the indexer.
The keyword is used to define the value being assigned by the set
accessor.
Indexers do not have to be indexed by an integer value; it is up to you how to define the specific look-up mechanism.
Indexers can be overloaded.
Indexers can have more than one formal parameter, for example, when accessing a two-dimensional array.
Indexers allow instances of a class or struct to be indexed just like arrays. The indexed value can be set or retrieved without explicitly specifying a type or instance member. Indexers resemble properties except that their accessors take parameters.