To convert an enum
type to an int
type in C#, you can use type casting. You can simply assign the value of the enum
type to a variable of type int
. For example:
enum DaysOfTheWeek { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }
DaysOfTheWeek day = DaysOfTheWeek.Tuesday;
int dayAsInt = (int)day;