Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
It's easier than you think - an enum is already an int. ItIt just needs to be reminded:
int y = (int)Question.Role; Console.WriteLine(y); // printsPrints 2
It's easier than you think - an enum is already an int. It just needs to be reminded:
int y = (int)Question.Role; Console.WriteLine(y); // prints 2
int y = (int)Question.Role; Console.WriteLine(y); // Prints 2
It's easier than you think - youran enum is already an intint. It It just needs to be reminded:
int
Every enumeration type has an underlying type, which can be any integral type, except char.
char
It's easier than you think - your enum is already an int. It just needs to be reminded:
It's easier than you think - anyour enum is already an intint. ItIt just needs to be reminded: