5.1常量
常量的定义
Const 变量类型 变量名=值
5.2枚举
枚举的声明
public enum 枚举名{
值1,值2,值3,...
}
有点类似于C++中的结构体,可以有利于开发
5.3枚举类型,int类型,string类型的相互转换
(1)枚举类型和int类型的相互转换
枚举转int:int num=(int)student.xxx
int转枚举:student stu1=(student)num
(2)枚举类型和string类型的相互转化
枚举转string:string str1=student.Tosring()
字符串类型转枚举类型:student stu1=(student)Enum.Parse(typeof(student),str1);
5.4数组
定义:数组就是可以一次性声明几个相同类型的变量名
定义方式:
int[] num=new int[10];
int[] num={1,2,3,4};
int[] num=new int[4]{1,2,3,4};
一般使用第四种较多
{案例:数组中找最大值}
{案例:冒泡排序}