C#enum枚举

  枚举:把有限的元素放在一起。使用字母代替数字标示的含义。枚举是一个值类型。

现在练习一下:

using System;
public enum Seasons{spring,summer,autumn=6,winter}
public  enum Weekday{one,two,three,four,five,six,seven}
 public class studyEnum
 {
	 public static void Main()
	 {
	    Seasons s = Seasons.spring;
		Console.WriteLine(s);
		Seasons a = Seasons.summer;
		 Console.WriteLine((int)a);
		Seasons b = Seasons.autumn;
		Console.WriteLine((int)b);
		Seasons c = Seasons.winter;
		 Console.WriteLine((int)c);
		 Weekday w = Weekday.four;
		 Console.WriteLine(w);
		 Weekday t = Weekday.six;
		 Console.WriteLine((int)t);
	 }
 }

 

posted @ 2012-08-04 14:49  妍珊  阅读(339)  评论(0编辑  收藏  举报