Answer 1)
C# introduces a new concept known as Indexers which are used for treating an object as an array. The indexers are usually known as smart arrays in C# community. 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 (get/set) take parameters.
Indexers are most frequently implemented in types whose primary purpose is to encapsulate an internal collection or array. And also, as C# does not support parameterized properties, sometimes we implement indexers as alternatives.
To declare an indexer on a class or struct, use the this keyword, as in this example:
[Code=cs]public int this[int index] // Indexer declaration
{
// get and set accessors
} [/Code] |