Going through all the values in an enum

  • Thread starter Thread starter UJ
  • Start date Start date
U

UJ

I've got an enum and want to spin through them in a foreach loop. How do I
go about doing that? I'm getting an error of Does not contain a definition
for GetEnumerator

TIA - Jeff.
 
Enum.GetValues(yourenum)

i.e.

foreach(YourEnum e in Enum.GetValues(YourEnum)) {
Console.WriteLine(e);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top