C#的枚举用法(原创)--王超C#

enum sex
    { 
    nan,nv
    }
    class Program
    {
        static void Main(string[] args)
        {

            sex w = sex.nan;
            Console.WriteLine(w);
            Console.ReadKey();
        }
    }


不要觉得制定nan=3没什么用,其实可以判断的.

enum sex
    { 
        nan=3,
        nv
    }
    class Program
    {
        static void Main(string[] args)
        {
            sex w = sex.nan;

            if(Convert.ToInt32(w)==3)
            {
            Console.WriteLine("chenggong");
            Console.ReadKey();
            }
        }
    }

 

posted on 2013-01-16 16:41  王超  阅读(157)  评论(0)    收藏  举报