I have been troubled by this for a while now, this is the code I have:
TILArray = new string[Width, Height];
int t = 0;
TILArray[t, t] = "";
TILArray[t, t] = "";
for (int x = 0; x < Width; x++)
{
for (int y = 0; y < Height; y++)
{
if (TILList[x][y] != null)
{
TILArray[0, 0] = TILList[x][y];
Tiles[x, y] = Content.Load<Tile>(TILList[x][y]);
}// This line throws the excetion
}
}
The line that throws the exception is actually the right curly brace marked above.
An unhandled exception of type ‘System.NullReferenceException’ occurred in TileEngine.dll
Additional information: Object reference not set to an instance of an object.
I needed to reinitialize the Tiles array when I set the width and height
That fixed it