Monday, June 15, 2009

Looping in Enum

C# Code

public
enum Suits
{
Spades,
Hearts,
Clubs,
Diamonds,
NumSuits
}

public void PrintAllSuits()
{
foreach(string name in Enum.GetNames(typeof(Suits)))
{
System.Console.WriteLine(suit);
}
}

No comments:

Post a Comment