Possible Duplicate:
How do I enumerate an enum?
I don't know if it is possible to do what I want to do, but I think why not.
I have example enum:
public enum Animals {
Cat,
Dog,
...
}
What I want to do is to iterate on this enum. I want it work like that:
foreach( var type in Animals ) {
Console.WriteLine( type.toString() );
}
and the output will be:
Cat
Dog
Is it possible? I don't want to put every item to an array, and then iterate, I want to iterate directly on this enum.