Converting Enums to Integer value

Poster
Posted by Poster under C# category on | Views : 4149
Lets say you have an enums like below

Enum Title
{
Mr = 1,
Mrs = 2,
Doctor = 3
}


When you simply write Title.Doctor.ToString(), you will get the "Doctor" but if you want to get 3 as value, you need to convert into Integer type like below.

int intValue = Convert.ToInt32(Title.Doctor);


Here in the intValue you will have 3.

Thanks

Comments or Responses

Login to post response