# Multi-Dimensional Arrays

Rectangular Arrays - These are really 2 dimensional. The number of rows is identical to the number of columns.
Jagged Arrays - These are not really 2 dimensional and represent a 1 dimensional array of 1 dimensional arrays. Each element in the main array can hold an array of varying length.

Arrays with mutiple dimensions are also referred to as jagged arrays.

`string[,] asMulti = new string[5,5]; `

Conceptually, a multidimensional array with two dimensions resembles a grid. A multidimensional array with three dimensions resembles a cube.

`int[,] array2D = new int[2,3]; int[,] array2D2 = { {1, 2, 3}, {4, 5, 6} }; `

`for (int i=0; i<2; i++) {     for (int j=0; j<3; j++)     {         array2D[i,j] = (i + 1) * (j + 1);     } } `

`for (int i=0; i<2; i++) {     for (int j=0; j<3; j++)     {         System.Console.Write(array2D[i,j]);     }     System.Console.WriteLine(); } int[] numbers = { 4, 5, 6, 1, 2, 3, -2, -1, 0 }; foreach (int i in numbers) {     System.Console.Write("{0} ", i); } `