C# Type IsEnum

Description

Type IsEnum gets a value indicating whether the current Type represents an enumeration.

Syntax

Type.IsEnum has the following syntax.


public virtual bool IsEnum { get; }

Example

The following example demonstrates how to use the IsEnum property.


//  ww w .  j a  v a2 s  .  c o m
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);
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version