2
Reply

What is an Enum in C#?

Sanjay Dixit

Sanjay Dixit

11y
1.2k
0
Reply

    In C#, enum is a value type data type. The enum is used to declare a list of named integer constants. It can be defined using the enum keyword directly inside a namespace, class, or structure. The enum is used to give a name to each constant so that the constant integer can be referred using its name. Example: enum WeekDays {Monday = 0,Tuesday =1,Wednesday = 2,Thursday = 3,Friday = 4,Saturday =5,Sunday = 6 }Console.WriteLine(WeekDays.Friday); Console.WriteLine((int)WeekDays.Friday);

    Enum in C# is reference type. Enum is a distinct type that consists of a set of named constants called the enumerator list.