// C# program to illustrate the
// Multidimensional Indexers
using System;
class Geeks
{
// reference to underlying 2D array
int[,] data = new int[5, 5];
// declaring Multidimensional Indexer
public int this[int ind1, int ind2]
{
// get accessor
get
{
// it returns the values which
// read the indexes
return data[ind1, ind2];
}
// set accessor
set
{
// write the values in 'data'
// using value keyword
data[ind1, ind2] = value;
}
}
}
class main
{
public static void Main(String[] args)
{
// creating the instance of
// Class Geeks as "ind"
Geeks ind = new Geeks();
// assign the values accordingly to
// the indexes of the array
// 1st row
ind[0, 0] = 1;
ind[0, 1] = 2;
ind[0, 2] = 3;
// 2nd row
ind[1, 0] = 4;
ind[1, 1] = 5;
ind[1, 2] = 6;
// 3rd row
ind[2, 0] = 7;
ind[2, 1] = 8;
ind[2, 2] = 9;
Console.WriteLine("{0}\t{1}\t{2}\n{3}\t{4}\t{5}\n{6}\t{7}\t{8}",
ind[0, 0], ind[0, 1], ind[0, 2],
ind[1, 0], ind[1, 1], ind[1, 2],
ind[2, 0], ind[2, 1], ind[2, 2]);
}
}