enum backend value

To change the enum backend value we specify the value for the constant.


using System;
enum WeekDay
{
    Monday = 4, Tuesday, Wednesday, Thursday = 10, Friday, Saturday, Sunday
}

class Test
{
    static void Main()
    {
        WeekDay day = WeekDay.Monday;
        if (day == (WeekDay)4)
        {
            Console.WriteLine("it is Monday");
        }
    }
}

The output:


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.