Initializing Arrays
C# provides simple and straightforward ways to initialize arrays at declaration time by enclosing the initial values in curly braces ({}). It is important to note that array members are automatically initialized to the default initial value for the array type if the array is not initialized at the time it is declared. The following examples show different ways to initialize different kinds of arrays.Single-Dimensional Array
int[] numbers = new int[5] {1, 2, 3, 4, 5};
string[] names = new string[3] {"Matt", "Joanne", "Robert"};
You can omit the size of the array, like this:int[] numbers = new int[] {1, 2, 3, 4, 5};
string[] names = new string[] {"Matt", "Joanne", "Robert"};
You can also omit the new statement if an initializer is provided, like this:int[] numbers = {1, 2, 3, 4, 5};
string[] names = {"Matt", "Joanne", "Robert"};
Multidimensional Array
int[,] numbers = new int[3, 2] { {1, 2}, {3, 4}, {5, 6} };
string[,] siblings = new string[2, 2] { {"Mike","Amy"}, {"Mary","Albert"} };
You can omit the size of the array, like this:int[,] numbers = new int[,] { {1, 2}, {3, 4}, {5, 6} };
string[,] siblings = new string[,] { {"Mike","Amy"}, {"Mary","Ray"} };
You can also omit the new statement if an initializer is provided, like this:int[,] numbers = { {1, 2}, {3, 4}, {5, 6} };
string[,] siblings = { {"Mike", "Amy"}, {"Mary", "Albert"} };
Jagged Array (Array-of-Arrays)
You can initialize jagged arrays like this example:int[][] numbers = new int[2][] { new int[] {2,3,4}, new int[] {5,6,7,8,9} };
You can also omit the size of the first array, like this:int[][] numbers = new int[][] { new int[] {2,3,4}, new int[] {5,6,7,8,9} };
-or-int[][] numbers = { new int[] {2,3,4}, new int[] {5,6,7,8,9} };
Notice that there is no initialization syntax for the elements of a jagged array. 

解决方案 »

  1.   

    你说应该是锯齿状数组吧,这有一个例子,应该对你有帮助
    class Control
    {
      ...
    }class Button : Control
    {
      ...
    }class Combo : Control
    {
      ...
    }class JaggedArrayApp
    {
        public static void Main()
       {
        Control[][] controls;//声明一个父数组
        controls = new Control[2][];    controls[0] = new Control[3];
        for (int i = 0; i < controls[0].Length; i++)
        {
          controls[0][i] = new Button();
        }    controls[1] = new Control[2];
        for (int i = 0; i < controls[1].Length; i++)
        {
          controls[1][i] = new Combo();
        }
      

  2.   

    Array可以包含所以的Object
    C#里面,Array也是一个Object
    也就是说Array可以包含Array