using System;
class MyArray2D {
public MyArray2D(int r, int c) {
}
// This is the indexer for MyArray2D.
public int this[int index1, int index2] {
// This is the get accessor.
get {
return index1 + index2;
}
}
}
class MainClass {
public static void Main() {
MyArray2D myArray = new MyArray2D(3, 5);
int x;
for(int i=0; i < 6; i++) {
x = myArray[i,i];
if(x != -1) Console.Write(x + " ");
}
Console.WriteLine();
}
}
|