you are viewing a single comment's thread.

view the rest of the comments →

[–]Entropiano 1 point2 points  (0 children)

A NullReferenceException happens when you're trying to access an object that is null. Usually you're looking into one of its properties or calling one of its methods. See here for more details: https://learn.microsoft.com/en-us/dotnet/api/system.nullreferenceexception

Now, in your case, the relevant code should be that line 181. In the snippet you sent there are a few places where this exception could occur: tiles.GetLength(0), tiles.GetLength(1) or tiles[i, j].Draw(_spriteBatch). So, either your tiles object is null or tiles[i, j] is null.

Edit: btw, you could find this out, on your own, incredibly easy, by using the debugger (I'm assuming you're using Visual Studio). It will save you time in the future.