这个问题可能非常基本,但我偶然发现了一行我从未见过的代码,并且想知道方括号的用途是什么。
public NodeItem (bool isWall, Vector2 pos, int x, int y)
{
this.isWall = isWall;
this.pos = pos;
this.x = x;
this.y = y;
}
1. private NodeItem[,] map;
2. map = new NodeItem[width, height];
有人可以向我解释 1 和 2 是如何工作的,这可能有什么好处吗?