代码循环遍历数组并将每个索引初始化为“*”。但是,我正在接受IndexOutOfRangeException
并Cave[i,j]
希望得到一些指导。
char[,] Cave = new char[GridHeight, GridWidth];
for (int i = 0; i < GridWidth; i++)
{
for (int j = 0; j < GridHeight; j++)
{
Cave[i, j] = '*'; //Error Here
}
}
为澄清起见
GridHeight
,GridWidth
声明如下public const int GridHeight = 5;
public const int GridWidth = 7;