Index out of bounds after I've already accessed that index less than 10 lines ago : <p>I'm creating a little text dungeon crawler and each floor of the dungeon is a 2d array of rooms. for some reason when you get to the third floor, after creating the array and making sure all rooms are set to null, when I'm setting up the rooms as soon as I get to floor3[1, 0] it throws an index out of bounds.</p>

<p>Having used break points and looking at the array it clearly has a [1,0] as well as everything else between [0,0] and [9,6]. I run a for loop that accesses that index and sets it to null and tried changing the for loop to instead change all the rooms to test rooms and it had no problem with that. I checked probably a dozen times to ensure that there aren't any typos, or that I'm trying to call the wrong floor or anything simple like that.  I also wrote just a simple Console.Writeline(floor[1,0]) test line to make sure that I wasn't just missing a typo, I removed that line and it also occurs on anything past that point. Again the identical method works for floors 1 and 2.</p>

<pre><code>floor3 = new RoomClass[9, 6];

//loop through everything and make sure that it's empty
for (int i = 0; i &lt; 9; i++)
{
    for (int j = 0; j &lt; 6; j++)
    {
        floor3[i, j] = null;
    }
}

//create rooms that actually need to exist.
floor3[0, 0] = new RoomClass("test1.", false, 0, 0);
floor3[0, 1] = new RoomClass("test2.", false, 0, 1);
floor3[0, 2] = new RoomClass("test5.", false, 0, 2);
floor3[0, 3] = new RoomClass("test3.", false, 0, 3);
floor3[0, 4] = new RoomClass("test4.", false, 0, 4);
floor3[0, 5] = new RoomClass("test5.", false, 0, 5);
floor3[0, 6] = new RoomClass("test5.", false, 0, 6);

floor3[1, 0] = new RoomClass("test6.", false, 1, 0);
floor3[1, 3] = new RoomClass("test7.", false, 1, 3);
floor3[1, 6] = new RoomClass("test8.", false, 1, 6);

floor3[2, 0] = new RoomClass("test9.", false, 2, 0);
(etc.)
</code></pre>

<p>This should just go through all the important indexes and create a room for each.</p>
