Multi-dimensional arrays C# with Example



Multi-dimensional arrays C# with Example

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 

0 Comment's

Comment Form

Submit Comment