MultiDimentional Arrays in C#

2D Array initialisation

int[,] a = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; 
int[,] a = new int[2,4];

3D Array initialisation

Its the same except with 3 commas

int[,,,] = new int[1,2,4];

Size of the array

arrayname.GetLength(dimention number) for a 2d array the dimention numbers would be 0 or 1 for the length/width.

arrayname.Length would give the total number of item spaces in the array.

Written on April 8, 2018