您的位置首页百科知识

C#中如何定义string数组?

C#中如何定义string数组?

的有关信息介绍如下:

C#中定义string数组方法:

1、定义一维数组

string[] parm=new string[]{"chinese","english","japan"};

2、一维字符串数组,如果提供了初始值设定项,则还可以省略 new 运算符

string[] par3={"chinese","english","japan"};

C#中如何定义string数组?

扩展资料

C#中其他类型数组定义方式介绍:

1、定义一维int数组

int[] numbers = new int[]{1,2,3,4,5,6,7,8,9,10}; //不定长数组

int[] numbers = new int[5]{1,2,3,4,5}; //定长数组

2、定义多维int数组

int[,] numbers = new int[,]{{1,2,3,4,5},{1,2,3,4,5}};  //不定长数组

int[,] numbers = new int[3,3]{{1,2,3},{1,2,3}};  //定长数组

3、一维对象数组

Object[] mf4 = new Object[5] { 26, 27, 28, 29, 30 };

4、二维整数数组,初值

mf5[0,0]=1,mf5[0,1]=2,mf5[1,0]=3,mf5[1,1]=4

int[,] mf5=new int[,]{{1,2},{3,4}};