日期:2014-05-17  浏览次数:20900 次

多维数组的索引该怎么设置
以下一维数组,测试通过

    public class aaa
    {
        int[] _numbers;
        public int this[int index1]
        {
            get
            {
                return _numbers[index1];
            }
        }
    }

想在多维数组中,该怎么设置?

    public class bbb
    {
        int[][] _numbers;
        public int this[int index1][int index2] //这里该怎么设置?
        {
            get
            {
                return _numbers[index1][index2];
            }
        }
    }

------解决方案--------------------
这样貌似也行:
public class bbb
{
int[][] _numbers;
public int[] this[int index] //这里该怎么设置?
{
get
{
return _numbers[index];
}
}
}

调用 bbb b = new bbb();
int value=b[3][2];