Create a multidimensional Array of the specified Type and dimension lengths, with zero-based indexing in CSharp
Description
The following code shows how to create a multidimensional Array of the specified Type and dimension lengths, with zero-based indexing.
Example
// ww w . j av a 2 s . c o m
using System;
public class SamplesArray {
public static void Main() {
int[] myLengthsArray = new int[4] { 2, 3, 4, 5 };
Array my4DArray=Array.CreateInstance( typeof(String), myLengthsArray );
for ( int i = my4DArray.GetLowerBound(0); i <= my4DArray.GetUpperBound(0); i++ )
for ( int j = my4DArray.GetLowerBound(1); j <= my4DArray.GetUpperBound(1); j++ )
for ( int k = my4DArray.GetLowerBound(2); k <= my4DArray.GetUpperBound(2); k++ )
for ( int l = my4DArray.GetLowerBound(3); l <= my4DArray.GetUpperBound(3); l++ ) {
}
}
}