C# Multidimensional Array

Multidimensional array has more than one dimension.

int[,] arr = new int[4,5]; //two dimentional array
int[,] arr = new int[,] {{2,3,4},{11,12,24}};
int elem = arr[0,0]; //elem=2
int elem2 = arr[1,1]; //elems=12

Get the total number of the array:
int num = arr.Length; //6

Get the dimension of the array:
int dim = arr.Rank; //2

Get the length of a given dimension:
int len = arr.GetLength(1); //3



endmemo.com © 2024  | Terms of Use | Privacy | Home