枚举型实质就是使用符号来表示的一组相互关联的数据.
Season currentSeason,nextSeason;
currentSeason = Season.Spring;
nextSeason = currentSeason + ;
Console.WriteLine("当前季节为:{0},{1}",int)currentSeason,currentSeason); Console.WriteLine("下一个季节为:{0}",nextSeason); Console.ReadKey(true); public enum Season
{
Spring = ,
Summer,
Autumn = ,
Winter, }
结构体用来描述一组相互关联的数据,用这些数据共同来描述一个完整事物。
Student stu;
stu.stu_no = ;
stu.stu_name = "陈";
stu.age = ;
stu.sex = "男";
Console.WriteLine("姓名:{0}",stu.stu_name);
Console.WriteLine("学号:{0}",stu.stu_no);
Console.WriteLine("年龄:{0}",stu.age);
Console.WriteLine("性别:{0}",stu.sex); struct Student
{
public int stu_no;
public string stu_name;
public int age;
public string sex;
}