For loops and enumeration

F

fred

If I have an enumeration where the values are not necessarily consecutive
can I do some sort of For each loop for each defined value. For example:

Public Enum CarType
Sedan = 2
Utility = 5
Van = 8
End Enum

For Each myCarType as CarType in CarType.Values
Obviously, this for loop doesn't work but is there some equivalent.

Thanks
Fred
 
M

Mattias Sjögren

For Each myCarType as CarType in CarType.Values
Obviously, this for loop doesn't work but is there some equivalent.

For Each myCarType as CarType in Enum.GetValues(GetType(CarType))



Mattias
 

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

Top