结构体和枚举

声明一个枚举类型,与struct的区别是:枚举里的变量都是整型的同类型,而struct是由不同类型的变量所组成的,默认情况下,枚举的第一个值为0,后面每个连续的元素值递增1。

 1    public struct ProductType 
 2     {
 3         public const string JOURNAL ="JOURNAL";
 4         public const string AUTHOR = "AUTHOR";
 5         public const string ORGAN = "ORGAN";
 6         public const string PUBLISHER = "PUBLISHER";
 7         public const string AREA = "AREA";
 8         public const string FUND = "FUND";
 9         public const string SUBJECT = "SUBJECT"; 
10     }
View Code

 

 1 enum WeekDay
 2     {
 3         Sunday,
 4         //Sunday = 1, 也可以直接赋值
 5         Monday,
 6         Tuesday,
 7         Wednesday,
 8         Thursday,
 9         Friday,
10         Saturday
11     };
View Code

 

posted @ 2016-03-08 09:05  ~沐风  阅读(473)  评论(0编辑  收藏  举报