Type.GetEnumUnderlyingType 方法

定义

返回当前枚举类型的基础类型。

C#
public virtual Type GetEnumUnderlyingType ();

返回

Type

当前枚举的基础类型。

例外

当前类型不是一个枚举。

  • 或 -

枚举类型无效,因为它包含多个实例字段。

注解

默认情况下,c # 和 Visual Basic 中的枚举的基础类型是 Int32 。 可以指定其他整数类型。

适用于

产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 2.0, 2.1