I'm a beginner to c# and I keep getting a 'System.NullReferenceException' error. I've looked everywhere but I can't seem to find a useful solution. I simplified the code below so that it would be more clear.
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.
}
}
}
The Tile-class is shown below
namespace tile_test
{
public class Tile
{
public bool active;
}
}
Could anyone help me out?