using System;
class DeclareArrayaSample
{
public static void Main()
{
//一维数组
int[] numbers=new int[5];
//多维数组
string[,] names= new string[5,4];
//不规则数组
byte[][] scores=new byte[5][];
//创建不规则数组
for(int i=0;i<scores.Lenghth;i++)
{
scores[i]=new byte[i+3];
}
//打印每一行的长度
for(int i=0;i<scores.Length;i++)
{
Console.WriteLine("Length of row{0} is {1}",i,scores[i].Length);
}
}
}
这个例子的输出是:
Length of row 0 is 3
Length of row 1 is 4
Length of row 2 is 5
Length of row 3 is 6
Length of row 4 is 7
|
|