Interviews2 answers
What is an Enum in C#?
2 Answers
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);
Samatha ReddyPosted Mar 16, 2017, 4:20 AM EDT
Enum in C# is reference type. Enum is a distinct type that consists of a set of named constants called the enumerator list.
Sasi KalaPosted Dec 3, 2013, 12:26 AM EST