I understand that the indexer is an access mechanism. For example, if you want to access an element of an array in the category class under normal circumstances, the access is like this: an object --> object name is generated by the instance. array name [index value]; if you add an index that is declared by the this keyword to the array in the class. in this way, you can create an object --> object name [index value]. you can access that element.
Of course, the code in the so-called indexer is also self-written, and the types and numbers of indexer parameters can be defined by themselves, so you can Index in different ways to find the data to be returned.
Example: by associating an indexer to an array, you can access
1 class A 2 {3 private int [] Arr = {1, 2, 3, 4, 5, 6, 7 }; 4 public int this [int I] 5 {6 get {return Arr [I];} 7 set {value = Arr [I];} 8} 9} 10 11 class Program12 {13 static void Main (string [] args) 14 {15 16 A = new a (); 17 Console. writeLine (a [3]); 18 Console. read (); 19 20}
At present, I have not realized any other overbearing aspects of the indexer.
It should be awesome.
Indexer