What is indexe? why we use it?
what is indexer in c# and how and why we use that in C#?
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
Sivaraman DhamodaranRank #40 · 34.5K reputationPosted Jul 17, 2015, 12:24 AM EDT
Nilesh JadavRank #109 · 20.3K reputationPosted Jul 17, 2015, 12:56 AM EDT
Indexers are one neat feature of C#. They allow us to access a particular class as it is an array. They are similar to the properties in means that they encapsulate method calls into more convenient representation of value access and value setting. Declaring a property you can access it with its name, so it behaves like variable. The indexer is actually a class so it behaves as a type, i.e. you have to declare a variable of its type (actually to instantiate an object from it, but all variables are objects anyway). Indexers are also called smart arrays in C# and can be used to treat an object as an array. An indexer allows an instance of a class or a struct to be indexed as an array, which is useful for looping or iterating or data binding operations. The following is the syntax of an indexer declaration.
Rajeesh MenothRank #118 · 18.4K reputationPosted Jul 17, 2015, 3:17 AM EDT
Govinda Rajulu YemineniRank #1,518 · 1K reputationPosted Jul 17, 2015, 3:45 AM EDT