C#中交错数组的初始化

 int[][,] arr = new int[2][,];
            arr[0] = new int[1, 2] { { 10,20} };
            arr[1] = new int[2, 3] { {1,2,3 }, {2,3,4} };

            for (int i = 0; i < arr.Length; i++) {
                for (int j = 0; j < arr[i].GetLength(0); j++) {
                    for (int k = 0; k < arr[i].GetLength(1); k++) {
                        Console.Write("A[{0}][{1},{2}] = {3}    ",i,j,k,arr[i][j,k]);
                    }
                }
            }

            Console.ReadKey();




int[][][] arr = new int[2][][];
            arr[0] = new int[2][];
            arr[1] = new int[2][];
            arr[0][0] = new int[2] { 1, 2 };
            arr[0][1] = new int[2] { 2, 3 };
            arr[1][0] = new int[2] { 3, 4 };
            arr[1][1] = new int[2] { 4, 5 };


你可能感兴趣的:(C#.Net程序设计)