Multi-dimensional arrays

suggest change

Arrays can have more than one dimension. The following example creates a two-dimensional array of ten rows and ten columns:

int[,] arr = new int[10, 10];

An array of three dimensions:

int[,,] arr = new int[10, 10, 10];

You can also initialize the array upon declaration:

int[,] arr = new int[4, 2] { {1, 1}, {2, 2}, {3, 3}, {4, 4} };

// Access a member of the multi-dimensional array:
Console.Out.WriteLine(arr[3, 1]);  // 4

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents