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
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());
}
}
}
Comments
Leave a comment