我有这样的代码:
int[, ,] data = new int[16, 32, 16];
for (int x = 0; x < data.GetLength(0); x++)
{
for (int z = 0; z < data.GetLength(1); z++)
{
for (int y = 0; x < data.GetLength(2); y++)
{
if (data[x, y, z] != 0)
{
// CODE
}
}
}
}
错误:IndexOutOfRangeException:数组索引超出范围。(wrapper managed-to-managed) object:ElementAddr (object,int,int,int)
当:X=0 Y=32 Z=0
我相信你在下面的语句中有一个打字错误:
for (int y = 0; x < data.GetLength(2); y++)
^
|
-----------------
应该是y < ...
吗?