Notifications
Clear all
2
16/12/2019 6:19 am
The following code produces below compilation error,
'WorkDay' is a 'type' but is used like a 'variable' -- fails on the foreach statement
public enum WorkDay
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday
}
foreach (WorkDay day in WorkDay)
{
DoSomething(day);
}
1 Answer
2
16/12/2019 6:41 am
foreach (WorkDay day in (WorkDay[]) Enum.GetValues(typeof(WorkDay)))
{
DoSomething(day);
}