int[,] twoDimensionalArray = new int[,]{ { 1, 2 },{ 4, 5 },{ 7, 8 }};
int rows = twoDimensionalArray.GetLength(0); // 获取二维数组的行数
int[] lie1 = new int[rows]; // 创建保存列数据的新一维数组
int[] lie2 = new int[rows]; // 创建保存行数据的新一维数组
// 将行数据存储在新一维数组中
for (int i = 0; i < rows; i++)
{
lie1[i] = twoDimensionalArray[i, 0];
lie2[i] = twoDimensionalArray[i, 1];
}
//// 打印结果
Console.WriteLine("Row Array:");
foreach (int row in lie1)
{
Console.Write(row + " ");
Console.WriteLine();
}
Console.WriteLine("\nColumn Array:");
foreach (int column in lie2)
{
Console.Write(column + " ");
Console.WriteLine();
}