Enums are always a favourite when we want to restrict users while sending some string to a generic methods. Was exploring how to get the text of the enum from the correspoing number. .Typecasting the number to the enum type would get the text from enum. Have shared a sample on this

Using System;

namespace ConsoleApplication1 {

class Program{

enum WeekDays { Sun = 1, Mon = 2, Tue, Wed, Thu, Fri, Sat }

staticvoid Main(string[] args) {

Console.WriteLine(((int)WeekDays.Thu).ToString());

Console.WriteLine(((WeekDays)1).ToString());

Console.Read();

}}}

Output :

5

Sun