public Enum Days
{
Monday = 1,
Tuesday = 2,
Wednesday = 3,
Thursday = 4,
Friday = 5,
Saturday = 6,
Sunday = 7
}
Now I wanted to know how do I get the integer value of an enum and convert an integer value into enum
Will
int dayNo = (int) Days.Monday;
change the value of dayNo to 1;
and
Will
Days day = (Days) 2;
assign Days.Tuesday to the variable day ??
How about is this the best way to do the parsing??
Yes it will do exactly that except
Enumshould beenumTo use Enum.Parse you MUST provide a string so if you want to cast from the int you’d have to go via a string which is ugly.
… both give you wednesday.