ArrayList testArrayList = new ArrayList();
int[,] testArray = { { 1, 23, 4, 5 }, { 23, 2, 56, 2 }, { 2, 22, 6, 8 } };
testArrayList.Add(testArray);
怎样正确输出这个多维数组呢?

解决方案 »

  1.   


    我是得不到多维数组的值
    testArrayList[0]  是object
    怎样转成多维数组
      

  2.   

            ArrayList testArrayList = new ArrayList();
            int[,] testArray = { { 1, 23, 4, 5 }, { 23, 2, 56, 2 }, { 2, 22, 6, 8 } };
            testArrayList.Add(testArray);             int[,] test = (int[,])testArrayList[0];
                 
                 Response.Write("<BR>");
                 foreach (int i in test)
                 {
                     Response.Write(i);
                     Response.Write("<BR>");
                 }
        }
      

  3.   

    或者用List<int[,]>代替ArrayList
      

  4.   

     ArrayList testArrayList = new ArrayList();
                int[,] testArray = { { 1, 23, 4, 5 }, { 23, 2, 56, 2 }, { 2, 22, 6, 8 } };
                testArrayList.Add(testArray);            int[,] test = (int[,])testArrayList[0];          
                foreach (int i in test)
                {
                    Console.WriteLine(i);
                }方法不错,
    建议用list<>