Enumerating Enums

Why can't you enumerate Enums?  You'd think you could, given the name!

What would it look like?

enum X { A, B, C, D }

foreach( X x in X ) { ... }

Okay, that won't fly because X is a type not an instance. 

How about:   foreach( X x in X.GetValues() )

Now, that would be possible, since you'd just be calling a static method that returns an enumable instance.

Why haven't we added this super-marvelous method to Enum's?  Dunno.  I suppose you could always write a static helper that enumerates enums using reflection.  Maybe one day the perf of reflection will have improved enough to make you want to.

I can always hope.

Matt