Indexer

Indexer (Indexer) is a special attribute. It can be added to a class, to provide access to array-like.

We give an example:

public  class Animals: the CollectionBase // inherits the base class set, he is an abstract class, comprising an interface IEnumerable, ICollection and the IList 
{
         ...
        public Animal thid[int animalIndex]
        {
                GET { return (Animal) List [animalIndex];} // This is a display data type conversion. 
                SET {List [animalIndex] = value;}
        }
}

Guess you like

Origin www.cnblogs.com/Mr-Prince/p/12148340.html