Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Type.IsEnum Property

Gets a value indicating whether the current Type represents an enumeration.

[Visual Basic]
Public ReadOnly Property IsEnum As Boolean
public bool IsEnum {get;}
public: __property bool get_IsEnum();
public function get IsEnum() : Boolean;

Property Value

true if the current Type represents an enumeration; otherwise, false.


This property returns true for an enumeration, but not for the Enum type itself, which is a class.

This property is read-only.


[Visual Basic, C#, C++] The following example demonstrates using the IsEnum property.

[Visual Basic] 
Imports System

Public Enum Color
End Enum 'Color
Class TestIsEnum
   Public Shared Sub Main()
        Dim colorType As Type = GetType(Color)
        Dim enumType As Type = GetType([Enum])
        Console.WriteLine("Is Color an enum? {0}.", colorType.IsEnum)
        Console.WriteLine("Is Color a value type? {0}.", colorType.IsValueType)
        Console.WriteLine("Is Enum an enum type? {0}.", enumType.IsEnum)
        Console.WriteLine("Is Enum a value type? {0}.", enumType.IsValueType)
    End Sub 'Main
End Class 'TestType

using System;
public enum Color 
Red, Blue, Green
class TestIsEnum 
    public static void Main() 
       Type colorType = typeof(Color);
       Type enumType = typeof(Enum);
       Console.WriteLine("Is Color an enum? {0}.", colorType.IsEnum);
       Console.WriteLine("Is Color a value type? {0}.", colorType.IsValueType);
       Console.WriteLine("Is Enum an enum Type? {0}.", enumType.IsEnum);
       Console.WriteLine("Is Enum a value type? {0}.", enumType.IsValueType);

#using <mscorlib.dll>

using namespace System;
__value enum Color {
   Red, Blue, Green

int main() {
   Type*  colorType = __typeof(Color);
   Type*  enumType = __typeof(Enum);
   Console::WriteLine(S"Is Color an enum? {0}.", __box(colorType->IsEnum));
   Console::WriteLine(S"Is Color a value type? {0}.", __box(colorType->IsValueType));
   Console::WriteLine(S"Is Enum an enum Type? {0}.", __box(enumType->IsEnum));
   Console::WriteLine(S"Is Enum a value type? {0}.", __box(enumType->IsValueType));

[Visual Basic, C#, C++] This code produces the following output:

Color is enum? True
Color is valueType? True
Enum is enum Type? False
Enum is value? False

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Type Class | Type Members | System Namespace | TypeAttributes

© 2017 Microsoft