枚举型实质就是使用符号来表示的一组相互关联的数据.
Season currentSeason,nextSeason; currentSeason = Season.Spring; nextSeason = currentSeason + 1; Console.WriteLine("当前季节为:{0},{1}",int)currentSeason,currentSeason); Console.WriteLine("下一个季节为:{0}",nextSeason); Console.ReadKey(true); public enum Season { Spring = 0, Summer, Autumn = 11, Winter, }
结构体用来描述一组相互关联的数据,用这些数据共同来描述一个完整事物。
Student stu; stu.stu_no = 0; stu.stu_name = "陈"; stu.age = 20; 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; }