我开始使用2D寻路引擎,但是它给了我2D数组构造函数中的下一个错误 在Field类中,它的实际数组有一个变量c
public void FieldBuild(
int LowerLeftX,
int LowerLeftY,
int UpperRightX,
int UpperRightY,
bool Walkable)
{
int CellsConstructed = 0;
for (int Xctr = LowerLeftX; Xctr <= UpperRightX; Xctr++)
{
for (int Yctr = LowerLeftY; Yctr <= UpperRightY; Yctr++)
{
this.c[Xctr,Yctr] = new Cell(Xctr, Yctr); //error on this line
this.c[Xctr,Yctr].IsWalkable = Walkable;
CellsConstructed++;
}
}
Console.WriteLine("Constructed {0} cells.", CellsConstructed);
}
告诉我它出现NullReferenceException
错误