博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C#的一维数组和二维数组定义方式:
阅读量:7127 次
发布时间:2019-06-28

本文共 779 字,大约阅读时间需要 2 分钟。

一维数组:

//一维数组定义与初始化              int[] one1 = new int[] {
3,2,1 };//第一种方式 int[] one2 = { 3, 2, 1 }; //第二种方式 int[] one3; //第三种方式 one3=new int[]{
3,2,1};

二维数组:

//二维数组定义与初始化                //不规则二维数组              int[][] array = new int[2][];              array[0] = new int[3];              array[0][1] = 11;              array[0][2] = 12;              array[1] = new int[] { 1, 2, 3, 4,5 };

要注意 

int[][] array = new int[2][];

这种声明方式,不能这样写:

int[][] array = new int[2][3];

不能直接声明二级数组大小,否则会报错。

//二维数组,先定义了一维:2 int[][] a = new int[2][];//再定义第二维: 3 a[0] = new int[3]{
1,2,3};a[1] = new int[3]{
4,5,6};

或者:

string[][] array = new string[length][];array[i] = new string[2];array[i][0] = d.Key;array[i][1] = d.Value;

 

转载地址:http://oohel.baihongyu.com/

你可能感兴趣的文章
C# 异常类型
查看>>
C语言realloc,malloc,calloc的区别【转载】
查看>>
SQL中采用Newtonsoft.Json处理json字符串
查看>>
jspace2d——A free 2d multiplayer space shooter
查看>>
Form 重置记录编号(app_record.for_all_record)
查看>>
VC之美化界面(内容覆盖十分全面,经典)
查看>>
国外经典设计:12个漂亮的移动APP网站案例
查看>>
pl/sql programming 15 数据提取
查看>>
DBCP(一)数据源配置文件
查看>>
C++ map 映照容器
查看>>
重新想象 Windows 8 Store Apps (40) - 剪切板: 复制/粘贴文本, html, 图片, 文件
查看>>
[WinAPI] API 13 [遍历指定目录 打印文件和其他属性]
查看>>
字对齐、半字对齐、字节对齐的理解
查看>>
杀毒软件导致YourSQLDba备份失败
查看>>
struts2漏洞原理及解决办法
查看>>
利用cca进行fmri分析
查看>>
Oracle Dataguard之switchover
查看>>
Step-by-Step XML Free Spring MVC 3 Configuration--reference
查看>>
关于LD_DEBUG (转载)
查看>>
linux2.6.30.4内核移植(4)——完善串口驱动
查看>>