enum foreach c# code example
Example 1: loop through an enum c#
public enum Days {
Monday,
Tuesday,
Wednesday
}
foreach(Days day in Enum.GetValues(typeof(Days))) {
}
Example 2: enum foreach
foreach (Suit suit in (Suit[]) Enum.GetValues(typeof(Suit)))
{
}
Example 3: c# foreach enum
enum Foos {
Foo,
Bar,
}
foreach(Foos val in Enum.GetValues(typeof(Foos))) {}