Create an enumeration named month that hold the values for the months of the year. Starting with January equal to 1.write a program that prompts the user a month's integers convert user's entry to a month's values,and display it
using System;
namespace ConsoleApp1
{
class Program
{
public enum Month
{
January = 1,
February,
March,
April,
May,
June,
July,
August,
September,
October,
November,
December
}
static void Main(string[] args)
{
string str = "";
int Number;
while (str != "Exit" && str != "E" && str != "exit" && str != "e")
{
Console.Write("Write a number from 1 to 12 (Or write the Exit): ");
str = Console.ReadLine();
if (int.TryParse(str, out Number))
if (Number >= 1 && Number <= 12)
Console.WriteLine((Month)Number);
}
}
}
}
Comments
Leave a comment