enum backend numeric type

If you have to change the backend numeric type for an enum type, here is the syntax:


enum EnumType: IntegerTypeName{
   ...
}

In the following code we create an enum type based on byte type.


using System;
enum WeekDay : byte
{
    Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
}


class Test
{
    static void Main()
    {
        WeekDay day = WeekDay.Monday;
        WeekDay day2 = WeekDay.Tuesday;

        Console.WriteLine(day > day2);

        if (day == WeekDay.Monday)
        {
            Console.WriteLine("it is monday");
        }

    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.