Multidimensional arrays are not commonly used. I think it is better to use XML.
Code
Class Arraytest
{
Public VoidTestarray (){
// Statement 1:
// String [,] items = new string [,] {
// {
// {"A1", "A2", "A3", "A4", "A5 "},
// {"B1", "B2", "B3", "B4", "B5 "},
// {"C1", "C2", "C3", "C4", "C5 "},
// {"D1", "D2", "D3", "D4", "D5 "}
// },
// {
// {"E1", "E2", "E3", "E4", "E5 "},
// {"F1", "F2", "F3", "F4", "F5 "},
// {"G1", "G2", "G3", "G4", "G5 "},
// {"H1", "h2", "H3", "H4", "H5 "}
// }
// };
// Statement 2:
// String [,] items = {
// {
// {"A1", "A2", "A3", "A4", "A5 "},
// {"B1", "B2", "B3", "B4", "B5 "},
// {"C1", "C2", "C3", "C4", "C5 "},
// {"D1", "D2", "D3", "D4", "D5 "}
// },
// {
// {"E1", "E2", "E3", "E4", "E5 "},
// {"F1", "F2", "F3", "F4", "F5 "},
// {"G1", "G2", "G3", "G4", "G5 "},
// {"H1", "h2", "H3", "H4", "H5 "}
// }
// };
// Statement 3:
String [,] items = New String [ 2 , 4 , 5 ] {
{
{ " A1 " , " A2 " , " A3 " , " A4 " , " A5 " },
{ " B1 " , " B2 " , " B3 " , " B4 " , " B5 " },
{ " C1 " , " C2 " , " C3 " , " C4 " , " C5 " },
{ " D1 " , " D2 " , " D3 " , " D4 " , " D5 " }
},
{
{ " E1 " , " E2 " , " E3 " , " E4 " , " E5 " },
{ " F1 " , " F2 " , " F3 " , " F4 " , " F5 " },
{ " G1 " , " G2 " , " G3 " , " G4 " , " G5 " },
{ " H1 " , " H2 " , " H3 " , " H4 " , " H5 " }
}
};
Console. writeline (items. Rank ); // Output 3, rank starts counting from 1, but indicates that a rank (dimension) starts from subscript 0
Console. writeline ( " Items. getupperbound (0) = " + Items. getupperbound ( 0 )); // Output 1
Console. writeline ( " Items. getupperbound (1) = " + Items. getupperbound ( 1 )); // Output 3
Console. writeline ( " Items. getupperbound (2) = " + Items. getupperbound ( 2 )); // Output 4
Console. writeline ( " Items. getlowerbound (0) = " + Items. getlowerbound ( 0 )); // Output 0
Console. writeline ( " Items. getlowerbound (1) = " + Items. getlowerbound ( 1 )); // Output 0
Console. writeline ( " Items. getlowerbound (2) = " + Items. getlowerbound ( 2 )); // Output 0
Console. writeline ( " Traverse output " );
For ( Int I = 0 ; I < Items. rank; I ++ )
{
Console. writeline ( " Items. getupperbound ( " + I + " ) = " + Items. getupperbound (I ));
Console. writeline ( " Items. getlowerbound ( " + I + " ) = " + Items. getlowerbound (I ));
}
For ( Int I = Items. getlowerbound ( 0 ); I <= Items. getupperbound ( 0 ); I ++ )
{
For ( Int J = Items. getlowerbound ( 1 ); J <= Items. getupperbound ( 1 ); J ++ )
{
For ( Int K = Items. getlowerbound ( 2 ); K <= Items. getupperbound ( 2 ); K ++ )
{
Console. Write (items [I, j, k] + " " );
}
Console. writeline ();
} }
Console. writeline ("Total number of elements in the array (length ):"+Items. Length );
Console. Readline ();
}
}