码迷,mamicode.com
首页 > 编程语言 > 详细

枚举型Enum和结构型Stuct

时间:2015-10-11 15:20:35      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

枚举型实质就是使用符号来表示的一组相互关联的数据.

 

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;
}

 

枚举型Enum和结构型Stuct

标签:

原文地址:http://www.cnblogs.com/bincoding/p/4869216.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!