声明:一维数组:int[] numbers;
多维数组:string[,] names;
数组的数组(交错的):byte[][] scores;
初始化:
一维数组
int[] numbers = new int[5] {1, 2, 3, 4, 5};
string[] names = new string[3] {"Matt", "Joanne", "Robert"};
可省略数组的大小,如下所示:
int[] numbers = new int[] {1, 2, 3, 4, 5};
string[] names = new string[] {"Matt", "Joanne", "Robert"};
如果提供了初始值设定项,则还可以省略 new 运算符,如下所示:
int[] numbers = {1, 2, 3, 4, 5};
string[] names = {"Matt", "Joanne", "Robert"};