Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Loop through elements in an enum
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Loop through elements in an enum
Miscellaneous
Thread ID:
01089721
Message ID:
01089721
Views:
72
Is there a way to loop through the elements in an enum (foreach or for loop)?

Consider the following enum:
private enum myEnum
{
	one,
	two,
	three,
	four
}
I know the enum can be looped like this but I have to hardcode the loop termination:
string s = "";
for (int i = 0 ; i < 4 ; i++)
{
	s += ((GlobalCategories)i).ToString();
}
MessageBox.Show(s);
Thanks,
Einar
Semper ubi sub ubi.
Next
Reply
Map
View

Click here to load this message in the networking platform