Thread: Enum Iteration
View Single Post
  #2 (permalink)  
Old 08-15-2007, 02:17 PM
shanePreater shanePreater is offline
Member
 
Join Date: Jul 2007
Location: England, Bath
Posts: 47
shanePreater is on a distinguished road
An Enum is strongly typed so, unlike c++, you can't implicitly cast from an enum to an int and vice versa.
To do your loop using the values() static function to get an array of MyEnum objects:
Code:
for(MyEnum myEnum : MyEnum.values()) { //Do stuff here! }
Hope that sorts you out,
Shane.
__________________
Shane Preater -
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote