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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Palle TechnologiesPosted Apr 22, 2014, 7:43 AM
Abhay ShankerPosted Apr 22, 2014, 7:34 AM
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/
VulpesPosted Apr 22, 2014, 5:56 AM
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'