Mono Class Library: System.Enum Overview | Members

System.Enum.GetUnderlyingType Method

Returns the underlying type of the specified enumeration type. [Edit]

[System.Runtime.InteropServices.ComVisible(true)]
public static Type GetUnderlyingType (Type enumType)

Parameters

enumType
The Type of an enumeration. [Edit]

Returns

A Type instance that describes the underlying type of enumType. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionenumType is a null reference. [Edit]
ArgumentExceptionenumType is not an enumeration type. [Edit]

Remarks

Documentation for this section has not yet been entered. [Edit]

Example

The following example demonstrates the Enum.GetUnderlyingType(Type) method.

C# Example
using System;
public enum Colors {
  Red,
  White,
  Blue
}
public class EnumUnderlyingTypeTest {
  public static void Main() {
     Type t = Colors.GetUnderlyingType( typeof(Colors) );
     Console.WriteLine("The underlying type of Colors is {0}.", t.ToString());
  }
}

The output is

The underlying type of Colors is System.Int32.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0