You can simply cast the value to the enum. Don't forget to set initial value for January or take into account that by default enum starts from 0;
Console application will be next:
class Program
{
public enum Month
{
January, February, March,
April, May, June, July, August,
Septemper, October, November, December
};
static void Main(string[] args)
{
Console.WriteLine("Enter the number of the month");
int monthValue = 0;
int.TryParse(Console.ReadLine(), out monthValue);
Console.WriteLine((Month)monthValue - 1);
Console.ReadKey();
}
}
in case you don't need temporary variable you could also really convert it to enum. But not forget to set default enum value
public enum Month
{
January = 1, February, March,
April, May, June, July, August,
Septemper, October, November, December
};
static void Main(string[] args)
{
Console.WriteLine("Enter the number of the month");
var input = Enum.Parse(typeof(Month), Console.ReadLine());
Console.WriteLine(input);
Console.ReadKey();
}