What is the use of indexer in c# and where it is used in realtime ?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 22, 2014, 1:56 AM EDT
In effect, you can access the elements of the collection from within the class or struct wrapper just like you would if you were accessing them directly.
For this reason, indexers are commonplace in any such class or struct and there are many examples in the .NET framework itself.
For example, a string can be thought of as an array of chars and the string indexer enables you to access the char at a specific index:
string s = "indexer";
char c = s[2]; // 'd'
Abhay ShankerRank #375 · 6.7K reputationPosted Apr 22, 2014, 3:34 AM EDT
Check below link for detail
http://msdn.microsoft.com/en-us/library/6x16t2tx.aspx
http://www.c-sharpcorner.com/UploadFile/senthurganesh/109172007050741AM/1.aspx
http://questpond.blog.com/2013/04/16/c-csharp-interview-questions-and-answers-what-are-indexers-in-net/
Palle TechnologiesRank #6,639 · 260 reputationPosted Apr 22, 2014, 3:43 AM EDT