We have use more than one index for an indexer.
using System;
class TwoD
{
int[,] matrix =
{
{0,1,2},
{3,4,5},
{6,7,8}
};
public int this[int i, int j]
{
get
{
return matrix[i, j];
}
}
}
class Program
{
static void Main(string[] args)
{
TwoD t = new TwoD();
Console.WriteLine(t[1, 1]);
}
}
The output:
4