CHAPTER 11 ADVANCED C# LANGUAGE FEATURES
}
Apart from using the this keyword, the indexer looks just like any other C# property declaration. For
example, the role of the get scope is to return the correct object to the caller. Here, we are doing so by
delegating the request to the indexer of the ArrayList object, as this class also supports an indexer. The
set scope is in charge of adding new Person objects, this is achieved by calling the Insert() method of
the ArrayList.
Indexers are yet another form of syntactic sugar, given that this functionality can also be achieved
using “normal” public methods such as AddPerson() or GetPerson(). Nevertheless, when you support
indexer methods on your custom collection types, they integrate well into the fabric of the .NET base
class libraries.
While creating indexer methods is quite commonplace when you are building custom collections,
do remember that g V