int[, ,] arr3 = new int[3, 2, 4] {{{1,2,3,4},{5,6,7,8}}, {{9,10,11,12},{13,14,15,16}},{{17,18,19,20},{21,22,23,24}}}; //使用foreach语句 Console.WriteLine("使用foreach语句遍历数组:"); foreach (int i in arr3) Console.Write(i + " "); //使用for循环 Console.WriteLine("\n使用for循环遍历数组:"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 4; k++) { Console.Write(arr3[i, j, k] + " "); } } } Console.ReadLine();
时间: 2024-10-11 17:01:25