C#学习笔记
2011-08-02 22:41
531 查看
1、 枚举类型:
value的值从0开始,可以重写赋值过程指定每个枚举的实际值。
枚举的基本类型有:byte sbyte short ushort int uint long ulong
2、结构体
3、数组
<baseType>[] <name>
数组必须在访问前初始化。
数组的初始化方法:
多维数组(矩形数组,每行个数相同)
数组的数组:
enum typeName { value 1, value 2, value 3, . . . value N } typeName varName;//声明 varName=typeName.value//赋值
value的值从0开始,可以重写赋值过程指定每个枚举的实际值。
枚举的基本类型有:byte sbyte short ushort int uint long ulong
2、结构体
struct route { public orientation direction; public double distance; } route myRoute; myRoute.direction = orientation.north; myRoute.distance = 2.5;
3、数组
<baseType>[] <name>
数组必须在访问前初始化。
数组的初始化方法:
int[] myArrary={5,5,5,5,5};//方法一 int[] myArray = new int[5];//方法二,对于数值类型其被初始化为0 int[] myArray = new int[5]{1,2,2,2,2};//方法三 const int arraySize = 5; int myArray = new int[arraySize]{1,1,1,1,1};
多维数组(矩形数组,每行个数相同)
<baseType>[,,]<name>; //赋值 double[,]hillHeight = new double[3,4];//方法一 double[,] hillHeight = {{1,2,3,4},{2,2,2,2},{3,2,3,2}};//方法二
数组的数组:
//声明 int[][] intArray; //初始化方法一 intArray = new int[2][]; intArray[0] = new int [3]; intArray[1] = new int[4]; //初始化方法二 intArry = new int[3][]{new int[]{1,2,3},new int[]{1},new int[]{1,2}}; //初始化方法三 int[][] intArray = {new int[]{1,2,3},new int[]{1},new int[]{1,2}};
相关文章推荐
- C# OpenCV学习笔记六之人脸识别/五官识别测试
- (原创)c#学习笔记03--变量和表达式03--变量01--简单类型
- C# 学习笔记
- imos 学习笔记四 录像 c#
- 【C#学习笔记】保存文件
- 黑马程序员之 C#学习笔记:Resharper安装和破解
- C# 特性学习笔记
- 36、我的C#学习笔记2
- (原创)c#学习笔记03--变量和表达式04--表达式02--赋值运算符
- C#学习笔记1-类型之间的转换 分享修改删除
- .NET深入学习笔记(2):C#中判断空字符串的4种方法性能比较与分析
- C#与图像处理学习笔记(三)
- 实战开发 C# 索引器学习笔记
- C#学习笔记——通用对话框
- (原创)c#学习笔记08--面向对象编程简介01--面向对象编程的含义03--对象的生命周期--构造函数和析构函数
- C#学习笔记(三)
- C# 学习笔记(三) ForEach遍历集合
- C#学习笔记
- 学习笔记之C#常量、枚举、结构、索引器
- c#学习笔记 跨线程触发自定义事件时,包装线程安全