What is an Indexer?

chinmay.sahoo

New member
• Indexers permit instances of a class or struct to be indexed in the same way as arrays.

• Indexers are similar to properties except that their accessors take parameters.

• The indexers are usually known as smart arrays in C#.

• An indexer, also called an indexed property, is a class property that allows you to access a member variable of a class using the features of an array.

• Defining an indexer allows you to create classes that act like virtual arrays. Instances of that class can be accessed using the [] array access operator.
 
Hello,

Thank You for the informative.

The indexers are usually known as smart arrays in C# community. Defining a C# indexer is much like defining properties. We can say that an indexer is a member that enables an object to be indexed in the same way as an array. An indexer is also similar to a property. As with properties, you use get and set when defining an indexer. Unlike properties, you are not obtaining a specific data member; rather, you are obtaining a value from the object itself. When you define a property, you define a property name.
 
In object-oriented development, an indexer allows circumstances of a particular category or struct to be listed just like arrays.
 
Back
Top