I need to get dynamically all sizes of a multidimensional array ( [,] ). The first size is get by intOldTab.Length but how do we get others size of the array?
Thks
Added green "resolved" checkmark - Hack
Printable View
I need to get dynamically all sizes of a multidimensional array ( [,] ). The first size is get by intOldTab.Length but how do we get others size of the array?
Thks
Added green "resolved" checkmark - Hack
I've found that the method "GetLowerBound" and "GetUpperBound" can mess with the rank of each size of the array. Can someone confirm that it's through theses method I can acces all dimensions of the array?
I've found out.
Here's the code for a 2 dimensionnal array [,] only
int[,] intretTableau = new int[intLeTableau.GetUpperBound(0) + 1, intLeTableau.GetUpperBound(intLeTableau.Rank - 1) + 1];
For more that 2 dimensions:
GetUpperBound(n) retrieve the nth dimension of your array [,,,, ... ,,,,]
the +1 is for initialization purpose because GetUpperBound return the length of the dimension -1.
so
GetUpperBound(0) retrieve the maximum for the first dimension
GetUpperBound(1) retrieve the maximum for the second dimension
GetUpperBound(2) retrieve the maximum for the third dimension
.
.
.
GetUpperBound(n) retrieve the maximum for the nth dimension
VoilĂ !