Answer to Question #343818 in C# for Siyanda

Question #343818

Create an enumeration named Month that holds values for the months of the year, starting with

January equal to 1. Write a program that prompts the user for a month integer. Convert the

user’s entry to a Month value, and display it.


Make use of methods and arrays


1
Expert's answer
2022-05-22T18:09:33-0400
using System;


namespace Task
{
    enum Month
    {
        January = 1,
        February = 2,
        March = 3,
        April = 4,
        May = 5,
        June = 6,
        July = 7,
        August = 8,
        September = 9,
        October = 10,
        November = 11,
        December = 12
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter month number: ");
            int month_num = Convert.ToInt32(Console.ReadLine());
            Month month = (Month)month_num;
            Console.WriteLine(month.ToString());
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS