本帖最后由 夏闯富 于 2013-10-8 09:00 编辑
控制台是一种傻瓜性质的输出,你想输出二维数组,必须先给输出结果布局好- int[,] a = new int[3, 5] { { 1, 2, 3, 4, 5 }, { 11, 22, 33, 44, 55 }, { 111, 222, 333, 444, 555 } };
- Console.WriteLine("a的维度为:{0}", a.Rank);
- Console.WriteLine("a的长度为:{0}", a.Length);
- for (int i = 0; i < a.GetLength(0); i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- {
- Console.Write("a[{0},{1}] = {2} \t", i, j, a[i, j]);
- }
- Console.WriteLine();
- }
- Console.ReadKey();
复制代码 |