标签:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*
* 1、枚举是值类型
* 2、成员只有一种类型:命名的整数值常量
* 3、成员声明列表以逗号隔开
* 4、后一个成员比前一个增1
* 5、不能有重复的名称,但可以有重复的值
*/
namespace exEnum
{
enum TrafficLight
{
Green,
Yellow,
Red=99,
Black=99,
Pink
}
class Program
{
static void Main(string[] args)
{
TrafficLight t1 = TrafficLight.Yellow;
TrafficLight t2 = TrafficLight.Red;
TrafficLight t3 = TrafficLight.Pink;
TrafficLight t4 = TrafficLight.Black;
Console.WriteLine("{0},\t{1}",t1,(int)t1);
Console.WriteLine("{0},\t{1}", t2, (int)t2);
Console.WriteLine("{0},\t{1}", t3, (int)t3);
Console.WriteLine("{0},\t{1}", t4, (int)t4);
Console.ReadKey();
}
}
}
C#枚举
标签:
原文地址:http://www.cnblogs.com/sulong/p/4797337.html