【原】C#二维数组的遍历
int[,] array = new int[3,2];
array[0,0] = 1;
array[1,0] = 2;
array[2,0] = 3;
array[0,1] = 4;
array[1,1] = 5;
array[2,1] = 6;
Console.WriteLine("数组的长度为{0}", array.Length);
/*
Console.WriteLine(array.GetLength(0));
Console.WriteLine(array.GetLength(1));
*/
for (int i = 0; i < array.GetLength(0); i++)
{
for (int j = 0; j < array.GetLength(1); j++)
{
Console.WriteLine(array[i, j]);
}
}
array[0,0] = 1;
array[1,0] = 2;
array[2,0] = 3;
array[0,1] = 4;
array[1,1] = 5;
array[2,1] = 6;
Console.WriteLine("数组的长度为{0}", array.Length);
/*
Console.WriteLine(array.GetLength(0));
Console.WriteLine(array.GetLength(1));
*/
for (int i = 0; i < array.GetLength(0); i++)
{
for (int j = 0; j < array.GetLength(1); j++)
{
Console.WriteLine(array[i, j]);
}
}