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 463 views
1 answer 304 views
304 views asked Sep 21, 2018 by avibootz
1 answer 239 views
1 answer 213 views
213 views asked Sep 12, 2020 by avibootz
1 answer 300 views
1 answer 226 views
226 views asked Jan 16, 2017 by avibootz
1 answer 245 views
...