Test if an object is an Enum

Aran Mulholland picture Aran Mulholland · May 27, 2010 · Viewed 36.4k times · Source

I would like to know if 'theObject' is an enum (of any enum type)

 foreach (var item in Enum.GetValues(theObject.GetType())) {

     //do something
 }

Answer

EMP picture EMP · May 27, 2010

The question is the answer. :)

bool isEnum = theObject is Enum;