1 // cs_keyword_indexers.cs
5 private int [] myArray
= new int[100];
6 public int this [int index
] // indexer declaration
10 // Check the index limits
11 if (index
< 0 || index
>= 100)
14 return myArray
[index
];
18 if (!(index
< 0 || index
>= 100))
19 myArray
[index
] = value;
24 public class MainClass
26 public static void Main()
28 IndexerClass b
= new IndexerClass();
29 // call the indexer to initialize the elements #3 and #5:
32 for (int i
=0; i
<=10; i
++)
34 Console
.WriteLine("Element #{0} = {1}", i
, b
[i
]);