Monday, June 10, 2013

C# Declaring enum Variable

Example
using System;
namespace EnumApplication
{
    class EnumProgram
    {
        enum Days { Sun, Mon, tue, Wed, thu, Fri, Sat };
        static void Main(string[] args)
        {
             int WeekdayStart = (int)Days.Mon;
             int WeekdayEnd = (int)Days.Fri;
             Console.WriteLine("Monday: {0}", WeekdayStart);
             Console.WriteLine("Friday: {0}", WeekdayEnd);
             Console.ReadKey();
        }
    }
}

Result
Monday:1
Friday:5

No comments:

Post a Comment