int[,] arr = new int[3, 4] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
int x = arr.GetLength(0);
int y = arr.GetLength(1);
int[,] arrNew = new int[y,x];
print("X为" + x + "Y为" + y);
for (int i = 0; i < x; i++)
{
for (int j = 0; j < y; j++)
{
arrNew[j, i] = arr[i, j];
print(arrNew[j, i]);
}
}
Unity 二维数组的转置
最新推荐文章于 2024-09-14 09:17:47 发布