私は C# の初心者ですが、「System.NullReferenceException」エラーが発生し続けます。私はいたるところを見てきましたが、有用な解決策が見つからないようです。より明確になるように、以下のコードを単純化しました。
namespace tile_test
{
public class Game1 : Game
{
public static float bottomWorld = 38400f;
public static float rightWorld = 134400f;
public static int maxTilesX = (int)rightWorld / 16 + 1;
public static int maxTilesY = (int)bottomWorld / 16 + 1;
public Game1()
{
Tile[,] tile = new Tile[maxTilesX, maxTilesY];
int x = 1;
int y = 1;
tile[x, y].active = false; //Error on this line.
}
}
}
Tile クラスを以下に示します。
namespace tile_test
{
public class Tile
{
public bool active;
}
}
誰か助けてくれませんか?