Create three-dimensional Array of the specified Type and dimension, with zero-based indexing in CSharp
Description
The following code shows how to create three-dimensional Array of the specified Type and dimension, with zero-based indexing.
Example
//from w w w .jav a2s .c o m
using System;
public class SamplesArray {
public static void Main() {
Array my3DArray=Array.CreateInstance( typeof(Object), 2, 3, 4 );
for ( int i = my3DArray.GetLowerBound(0); i <= my3DArray.GetUpperBound(0); i++ )
for ( int j = my3DArray.GetLowerBound(1); j <= my3DArray.GetUpperBound(1); j++ )
for ( int k = my3DArray.GetLowerBound(2); k <= my3DArray.GetUpperBound(2); k++ ){
my3DArray.SetValue( "abc", i, j, k );
Console.WriteLine("abc");
}
}
}
The code above generates the following result.