Freigeben über


Enum.GetUnderlyingType-Methode

Gibt den zugrunde liegenden Typ der angegebenen Enumeration zurück.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
<ComVisibleAttribute(True)> _
Public Shared Function GetUnderlyingType ( _
    enumType As Type _
) As Type
'Usage
Dim enumType As Type
Dim returnValue As Type

returnValue = Enum.GetUnderlyingType(enumType)
[ComVisibleAttribute(true)] 
public static Type GetUnderlyingType (
    Type enumType
)
[ComVisibleAttribute(true)] 
public:
static Type^ GetUnderlyingType (
    Type^ enumType
)
/** @attribute ComVisibleAttribute(true) */ 
public static Type GetUnderlyingType (
    Type enumType
)
ComVisibleAttribute(true) 
public static function GetUnderlyingType (
    enumType : Type
) : Type

Parameter

  • enumType
    Ein Enumerationstyp.

Rückgabewert

Der enumType zugrunde liegende Type.

Ausnahmen

Ausnahmetyp Bedingung

ArgumentNullException

enumType ist NULL (Nothing in Visual Basic).

ArgumentException

enumType ist keine Enum.

Hinweise

Das folgende Codebeispiel veranschaulicht die Verwendung von GetUnderlyingType.

Shared Function GetAsUnderlyingType(enval As [Enum]) As Object
   Dim entype As Type = enval.GetType()
   
   Dim undertype As Type = [Enum].GetUnderlyingType(entype)
   
   Return Convert.ChangeType(enval, undertype)
End Function
static object GetAsUnderlyingType(Enum enval)
{
    Type entype = enval.GetType();

    Type undertype = Enum.GetUnderlyingType(entype);

    return Convert.ChangeType( enval, undertype );
}
Object^ GetAsUnderlyingType( Enum ^ enval )
{
   Console::WriteLine(  "GetAsUnderlying" );
   Type^ entype = enval->GetType();
   Type^ undertype = Enum::GetUnderlyingType( entype );
   return Convert::ChangeType( (Object^)(enval), undertype );
}
static function GetAsUnderlyingType(enval : Enum) : Object
{
    var entype : Type = enval.GetType();

    var undertype : Type = Enum.GetUnderlyingType(entype);

    return Convert.ChangeType( enval, undertype );
}

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

Enum-Struktur
Enum-Member
System-Namespace
GetTypeCode