Gets a bool value that indicates whether the current Type represents an enumeration.
true if the current Type represents an enumeration; otherwise false.
This property is read-only.
This property returns true for an enumeration, but not for the Enum type itself, which is a class.
If the current instance represents a generic type, this property applies to the definition of the type. If the current instance represents an unassigned type parameter of a generic type or method, this property always returns false.
The following example demonstrates using the Type.IsEnum property.
C# Example
using System; public enum Color { Red, Blue, Green } class TestType { public static void Main() { Type colorType = typeof(Color); Type enumType = typeof(Enum); Console.WriteLine("Color is enum ? {0}", colorType.IsEnum); Console.WriteLine("Color is valueType? {0}", colorType.IsValueType); Console.WriteLine("Enum is enum Type? {0}", enumType.IsEnum); Console.WriteLine("Enum is value? {0}", enumType.IsValueType); } }The output is
Color is enum ? True
Color is valueType? True
Enum is enum Type? False
Enum is value? False
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0