In C#, how do you enumerate an enum?
For example, the following code fails to compile:
public enum Suit
{
Spades,
Hearts,
Clubs,
Diamonds
}
public void EnumerateAllSuitsDemoMethod()
{
foreach (Suit suit in Suit)
{
DoSomething(suit);
}
}
The error that I get is related to Suit. What is going on? How to fix it?