Enum

We use an enum to declare named integer constants. We can declare them directly in a namespace, class and even in a struct directly. By default first member of enum has 0 value.

We use an enum to declare named integer constants. We can declare them directly in a namespace, class and even in a struct directly.

By default first member of enum has 0 value.

using System;

namespace Structures
{
    enum Week
    {
        Monday,
        Tuesday,
        Wednesday,
        Thrusday,
        Friday,
        Saturday,
        Sunday,
        Mon =12,
        Tue,
        Wed,
        Tru = 21,
        Fri =25,
        Sat =30,
        Sun
    }
    
    class Program
    { 
        static void Main(string[] args)
        {
            Console.WriteLine((int)Week.Monday);
            Console.WriteLine((int)Week.Tuesday);
            Console.WriteLine((int)Week.Wednesday);
            Console.WriteLine((int)Week.Thrusday);
            Console.WriteLine((int)Week.Friday);
            Console.WriteLine((int)Week.Saturday);
            Console.WriteLine((int)Week.Sunday);
            Console.WriteLine((int)Week.Mon);
            Console.WriteLine((int)Week.Tue);
            Console.WriteLine((int)Week.Wed);
            Console.WriteLine((int)Week.Tru);
            Console.WriteLine((int)Week.Fri);
            Console.WriteLine((int)Week.Sat);
            Console.WriteLine((int)Week.Sun);

            Console.ReadKey();
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *