|
|
Indexers in C# | Indexers are a kind of properties. Indexers let you use array notation on objects that are
instances of your own classes. |
Indexers allow access to data in an object with use of array notation |
This is a simple and somewhat artificial example of the use of indexers.
It is illustrated how three individual variables d, e, and f in class A can be accessed
as a[1], a[2], a[3], where a is an instance of class A. |
This is example shows a fine and realistic use of an indexer. The indexer
accesses the individual bits in a bit array. The bit array is represented as
a (relatively small) array of 32 bit integers. This example is taken from
the C# language specification. Please consult the text book version for
an explanation of the details. |