+ 1
How can we define a bidimensional array?
3 Réponses
+ 2
I search two ways to declare:
int [,] arr1 = new int[3,4];
int [,] arr2;
arr2 = new int[2,3];
+ 1
Thanks Julio.
0
yup, you can also do it this way:
int[,] arreglo = {{1,2,3,4},{5,6,7,8},{9,10,11,12}};
the dimensions length are like:
int[,] arreglo = new int[3,4];
remember the index starts at 0 so if...
int x = arreglo[1,2];
x would be 7 not 2 😀
and you can always get the bigger index of a dimension with
arreglo.Getupperbound(0); in this case it's 2
arreglo.Getupperbound(1); it's 3
so the last position is arreglo[2,3];😀
and last the length of each dimension with arreglo.GetLongLength(0); it's 3😀
I'm not so good with English...😅
Hope you find this useful😊