Foreach loop with 2d array of objects
- by Jacob Millward
I'm using a 2D array of objects to store data about tiles, or "blocks" in my gameworld. I initialise the array, fill it with data and then attempt to invoke the draw method of each object.
foreach (Block block in blockList)
{
block.Draw(spriteBatch);
}
I end up with an exception being thrown "Object reference is not set to an instance of…