C# Language Arrays Multi-dimensional arrays

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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


Got any C# Language Question?