Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Not understand the purpose of Indexers. Example:
C#
class MyCls
{
   object[] myArr = new object[];
   public object this[int i]
   {
      get{return myArr[i];}
      set{myArr[i] = value;}
   }
}

Why not just create a property for myArr and access it through it's property?
What's the advantage and/or purpose of using an Indexer?
Posted
Updated 3-Jan-12 19:47pm
v2

Right! Why not just create a property with the distinct name? There is nothing principal about this feature.


This is nothing more than the syntactic sugar, see http://en.wikipedia.org/wiki/Syntactic_sugar[^].

Being the syntactic sugar, this is very nice sugar, following nice tradition from other languages.



—SA
 
Share this answer
 
v3
hi
please refer below links

indexer tutorial
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900