C#创建多维数组代码
using System;
public class MultidimensionalArray
{
public static void Main()
{
int[] lowerBounds = {1, 2, 4};
int[] lengths = {4, 2, 1};
Console.WriteLine
("One dimensional array lower bound = {0}",
new string[10].GetLowerBound (0));
Array array = Array.CreateInstance
(typeof (int), lengths, lowerBounds);
Console.WriteLine
("Bounds dimension {0} = [{1},{2}]",
0, array.GetLowerBound (0), array.GetUpperBound (0));
Console.WriteLine
("Bounds dimension {0} = [{1},{2}]",
1, array.GetLowerBound (1), array.GetUpperBound (1));
Console.WriteLine
("Bounds dimension {0} = [{1},{2}]",
2, array.GetLowerBound (2), array.GetUpperBound (2));
}
}
执行结果
One dimensional array lower bound = 0 Bounds dimension 0 = [1,4] Bounds dimension 1 = [2,3] Bounds dimension 2 = [4,4]
