C#中如何定义string数组?
C#中定义string数组方法:
1、定义一维数组
string[] parm=new string[]{"chinese","english","japan"};
2、一维字符串游团郑数组,如果提供神颂了初始值或尺设定项,则还可以省略 new 运算符
string[] par3={"chinese","english","japan"};
扩展资料
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}};
string[] abc =new string[3];
abc[0]="1";
abc[1]="2"扰烂冲;
abc[2]="3"历颂;
方法二:
string[] abc=new string[]{"1"缓歼,"2","3"};
string[] abc=new string[4];
abc[0] = "aaa";
abc[1] = "bbb";
abc[2] = "ccc";
abc[3] = "ddd";