INDEXER IN C#
C# introduces a new concept Indexer. This is very useful for some situation. Let as discuss something about Indexer.
- Indexer Concept is object act as an array.
- Indexer an object to be indexed in the same way as an array.
- Indexer modifier can be private, public, protected or internal.
- The return type can be any valid C# types.
- Indexers in C# must have at least one parameter. Else the compiler will generate a compilation error.
- this [Parameter]
- {
- get
- {
- // Get codes goes here
- }
- set
- {
- // Set codes goes here
- }
- }
For Example
Farheen ZaheerPosted Nov 7, 2018, 4:13 AM
Need example of indexer in multi dimensional array and also with inheritance.
Farheen ZaheerPosted Nov 7, 2018, 4:11 AM
Nice Explanation and easy to understand. Very helpful, thanks.
David KiptooPosted Apr 14, 2018, 7:51 AM
Easy to understand. Indexes allow you to use an object as array
Sunil GuptaPosted Feb 5, 2018, 9:23 AM
Hey you explained properly, but still unclear what Indexer does. Real use is missing, it seems.
SubashPosted Jun 21, 2017, 9:32 PM
Little difficult in understand the example
Ankur ChaturvediPosted Sep 10, 2015, 6:18 AM
Nice article easy to understanding of concept ..Thanks alot
Upendra Pratap ShahiPosted Jun 12, 2015, 12:53 AM
good..
sarang chadPosted Oct 21, 2013, 11:25 AM
please tel me different types of indexers
Vidhya SagarPosted May 28, 2013, 6:31 AM
A good basic explanation.. :)
mohammed muddinPosted Nov 26, 2010, 1:52 PM
ur explanation is good, i hope u continue the same.thank you.
Md Mostafijur RahmanPosted Nov 16, 2008, 1:42 AM
simple....