Definition of Indexers from MSDN Indexers allow instances of a class or struct to be indexed just like arrays. Indexers resemble properties except that their accessors take parameters. Whenever you are accessing individual element from List<T> or Hashtable<T,T> etc you are using Indexers . For example List<string> str=new List<string>(); str.Add("Rameez"); str.Add("Usmani"); string firstName=str[0]; //[0] is implying that you are calling indexer on instance of List class How Indexer is added to a class To add an indexer to a class you have to expose a property named "this(actually a keyword)" followed by "data type of index" in square brackets . Like this public ReturnDataType this[indexDataType] { get { //logic to return the correct value } set { //logic to set the correct value } } Lets say you have collection of Students and you want to access Student by name using Indexer , here is h...
I document random stuff on this Blog. It can be a piece of code , my personal experience, a fun fact or anything else.