C#语法基础06_数组Array
C#语法基础06_数组Array
数组定长,存储单一数据类型
一维数组定义
type[] arrayname = new type[length]; // 定义
type[] arrayname = new type[] {value1, value2, ..., valueN}; // 初始化定义
type[] arrayname = {value1, value2, ..., valueN}; // 简略的初始化定义
二维数组定义
type[,] arrayname = new type[row, column];
type[,] arrayname = new type[]{ {value, value, value}, {value, value, value}, ...,{value, value, value} }; // 每个大括号表示一行的内容
type[,] arrayname = { {value, value, value}, {value, value, value}, ...,{value, value, value} };
三维数组定义
type[,,] arrayname = new type[row, column, table];
type[,,] arrayname = new type[] {}{ { {value, value, value}, {value, value, value},{value, value, value} }, { {value, value, value}, {value, value, value}, {value, value, value} }, { {value, value, value}, {value, value, value},{value, value, value} } };
// 可看作有 多张表 各表中均有行列
type[,,] arrayname = { { {value, value, value}, {value, value, value},{value, value, value} }, { {value, value, value}, {value, value, value}, {value, value, value} }, { {value, value, value}, {value, value, value},{value, value, value} } };
以数组作为元素的数组定义
type[][] rainfall = new type[num][];
rainfall[0] = new int[31];
rainfall[1] = new int[28];
rainfall[2] = new int[31];
rainfall[3] = new int[30];
·
·
·
rainfall[N] = new int[30];
moyutime:本文仅是学习心得,观点仅供参考,祝愿读者学习途中快乐且不断有所收获。