C# TypeInfo IsEnum

Description

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

Syntax

TypeInfo.IsEnum has the following syntax.


public virtual bool IsEnum { get; }

Example

The following example demonstrates how to use the IsEnum property.


/*from w  w w  .ja  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);
       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);
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo