实现效果:

  声明枚举变量_编程

实现代码:

    class Program
    {
        enum EmpType:byte           //EmpType的实际存储值设置为一个byte 而非int
        {
            Manager=102,
            Grunt,          //103
            Contractor,     //104
            vicepresident   //105
        }
        static void Main(string[] args)
        {
            Console.WriteLine("***Fun With Enum***");
            EmpType emp = EmpType.Contractor;   //创建职员类型 
            AskForBonus(emp);   
            Console.ReadLine();
        }
        static void AskForBonus(EmpType e)      //使用枚举作为参数
        {
            switch (e)
            {
                case EmpType.Manager:
                    Console.WriteLine("how about stock options instead?");
                    break;
                case EmpType.Grunt:
                    Console.WriteLine("you have got to be kidding...");
                    break;
                case EmpType.Contractor:
                    Console.WriteLine("you already get enough cash...");
                    break;
                case EmpType.vicepresident:
                    Console.WriteLine("VERY GOOD,SIR!");
                    break; ;
            }
        }