How to get values from Enum?

 Posted by vishalneeraj-24503 on 1/13/2014 | Category: C# Interview questions | Views: 630 | Points: 40
Answer:

Suppose i have below Enumeration values:-

public enum WeekDays

{
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
}


To get the values from Enum,we will write:-

int value1 = (int)WeekDays.Sunday; //output = 0;

string value2 = WeekDays.Sunday; //output = Sunday;


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response