KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How can you enumerate an enum in C#? E.g., the following code does not compile: public enum Suit { Spades, Hearts, Clubs, Diamonds } public void EnumerateAllSuitsDemoMethod() { foreach (Suit suit in Suit) { DoSomething(suit); } } And it gives the following compile-time error: 'Suit' is a 'type' but is used like a 'variable' It fails on the Suit keyword, the second one.
Tags (comma-separated)
Save Edits
Cancel