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
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |