How to use enum type byte that represent the 12 months of the year in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        enum Month : byte { Jan = 1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec };

        static void Main(string[] args)
        {
            Month m = Month.Aug;
            Console.WriteLine("{0} month number: {1}", m, (byte)m);
        }
    }
}


/*
run:

Aug month number: 8
 
*/

 



answered Aug 7, 2018 by avibootz
edited Aug 7, 2018 by avibootz

Related questions

1 answer 350 views
1 answer 202 views
202 views asked Sep 21, 2018 by avibootz
1 answer 156 views
1 answer 132 views
132 views asked Sep 12, 2020 by avibootz
1 answer 214 views
1 answer 144 views
144 views asked Jan 16, 2017 by avibootz
1 answer 149 views
...