InterviewSolution
Saved Bookmarks
| 1. |
Different way to fetch int values from enum in csharp? |
|
Answer» DIFFERENT way to fetch int values from ENUM in csharp? First we will define enum then will discuss the different conversion technique to convert them into int. public enum Study { subject = 2, COURSE = 3, books = 4, author = 5, } Here below we will create a object of enum and fetch the first Enum e = Study.subject; And below is the different conversion or parsing techniques int i = Convert.ToInt32(e); int i = (int)(object)e; int i = (int)Enum.Parse(e.GetType(), e.ToString()); int i = (int)Enum.ToObject(e.GetType(), e); |
|