## Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today. # Looping through a 3D jagged array

Trying to follow the example for the jagged array, but I'm getting NullReferenceException for my second for loop.

```            Cell[][][] threeDimensions = new Cell[][];

for (int i = 0; i < threeDimensions.Length; i++)
{
threeDimensions[i] = new Cell[];

for (int y = 0; y < threeDimensions[i].Length; y++)
{
threeDimensions[i][y] = new Cell;

for (int x = 0; x < threeDimensions[x].Length; x++)
{
threeDimensions[i][y][x] = new Cell();
}
}
}
``` It would be easier to analyze the issue with the entire project. To share that, make a snapshot of your workspace and post the link to it here. I did it in Visual Studios rather than workspace. I actually noticed the problem and fixed it myself, leaving the code here if someone else gets stuck :)

```namespace Collections
{
class Program
{
static void Main(string[] args)
{
Cell[][][] threeDimensions = new Cell[][];

for (int i = 0; i < threeDimensions.Length; i++)
{
threeDimensions[i] = new Cell[];

for (int y = 0; y < threeDimensions[i].Length; y++)
{
threeDimensions[i][y] = new Cell;

for (int x = 0; x < threeDimensions[i][y].Length; x++)
{
threeDimensions[i][y][x] = new Cell();
}
}
}
}

class Cell
{
public string Contents { get; set; }
}

}
``` ```                    for (int x = 0; x < threeDimensions[x].Length; x++)     // original