Enum 类

定义

为枚举提供基类。

public ref class Enum abstract : ValueType, IComparable, IConvertible, IFormattable
public ref class Enum abstract : ValueType, IComparable, IConvertible, ISpanFormattable
public ref class Enum abstract : ValueType, IComparable, IFormattable
public abstract class Enum : ValueType, IComparable, IConvertible, IFormattable
public abstract class Enum : ValueType, IComparable, IConvertible, ISpanFormattable
[System.Serializable]
public abstract class Enum : ValueType, IComparable, IConvertible, IFormattable
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Enum : ValueType, IComparable, IConvertible, IFormattable
public abstract class Enum : ValueType, IComparable, IFormattable
type Enum = class
    inherit ValueType
    interface IComparable
    interface IConvertible
    interface IFormattable
type Enum = class
    inherit ValueType
    interface IComparable
    interface IConvertible
    interface ISpanFormattable
    interface IFormattable
type Enum = class
    inherit ValueType
    interface IComparable
    interface IConvertible
    interface IFormattable
    interface ISpanFormattable
[<System.Serializable>]
type Enum = class
    inherit ValueType
    interface IComparable
    interface IFormattable
    interface IConvertible
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Enum = class
    inherit ValueType
    interface IComparable
    interface IFormattable
    interface IConvertible
type Enum = class
    inherit ValueType
    interface IComparable
    interface IFormattable
Public MustInherit Class Enum
Inherits ValueType
Implements IComparable, IConvertible, IFormattable
Public MustInherit Class Enum
Inherits ValueType
Implements IComparable, IConvertible, ISpanFormattable
Public MustInherit Class Enum
Inherits ValueType
Implements IComparable, IFormattable
继承
派生
属性
实现

注解

有关此 API 的详细信息,请参阅 枚举的补充 API 说明

构造函数

Enum()

初始化 Enum 类的新实例。

方法

CompareTo(Object)

将此实例与指定对象进行比较并返回一个对二者的相对值的指示。

Equals(Object)

返回一个值,该值指示此实例是否等于指定的对象。

Format(Type, Object, String)

根据指定格式将指定枚举类型的指定值转换为其等效的字符串表示形式。

GetHashCode()

返回该实例的值的哈希代码。

GetName(Type, Object)

在指定枚举中检索具有指定值的常数的名称。

GetName<TEnum>(TEnum)

在指定枚举类型中检索具有指定值的常数的名称。

GetNames(Type)

检索指定枚举中常数名称的数组。

GetNames<TEnum>()

检索指定枚举类型中常数名称的数组。

GetType()

获取当前实例的 Type

(继承自 Object)
GetTypeCode()

返回此枚举成员的基础类型的类型代码。

GetUnderlyingType(Type)

返回指定枚举的基础类型。

GetValues(Type)

检索指定枚举中常数值的数组。

GetValues<TEnum>()

检索指定枚举类型中常数值的数组。

GetValuesAsUnderlyingType(Type)

检索指定枚举中基础类型常量的值的数组。

GetValuesAsUnderlyingType<TEnum>()

检索指定枚举类型中基础类型常量的值的数组。

HasFlag(Enum)

确定当前实例中是否设置了一个或多个位域。

IsDefined(Type, Object)

返回一个布尔值,该值指示给定的整数值或其名称字符串是否存在于指定的枚举中。

IsDefined<TEnum>(TEnum)

返回一个布尔值,该值指示给定的整数值或其名称字符串是否存在于指定的枚举中。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
Parse(Type, ReadOnlySpan<Char>)

将一个或多个枚举常量的名称或数值的字符表示形式转换为等效的枚举对象。

Parse(Type, ReadOnlySpan<Char>, Boolean)

将一个或多个枚举常量的名称或数值的字符表示形式转换为等效的枚举对象。 一个参数指定该操作是否不区分大小写。

Parse(Type, String)

将一个或多个枚举常数的名称或数字值的字符串表示转换成等效的枚举对象。

Parse(Type, String, Boolean)

将一个或多个枚举常数的名称或数字值的字符串表示转换成等效的枚举对象。 一个参数指定该操作是否不区分大小写。

Parse<TEnum>(ReadOnlySpan<Char>)

将指定的 TEnum 一个或多个枚举常量的名称或数值的字符表示形式转换为等效的枚举对象。

Parse<TEnum>(ReadOnlySpan<Char>, Boolean)

将指定的 TEnum 一个或多个枚举常量的名称或数值的字符表示形式转换为等效的枚举对象。 一个参数指定该操作是否不区分大小写。

Parse<TEnum>(String)

TEnum 指定的一个或多个枚举常数的名称或数字值的字符串表示形式转换成等效的枚举对象。

Parse<TEnum>(String, Boolean)

TEnum 指定的一个或多个枚举常数的名称或数字值的字符串表示形式转换成等效的枚举对象。 一个参数指定该操作是否不区分大小写。

ToObject(Type, Byte)

将指定的 8 位无符号整数转换为枚举成员。

ToObject(Type, Int16)

将指定的 16 位有符号整数转换为枚举成员。

ToObject(Type, Int32)

将指定的 32 位有符号整数转换为枚举成员。

ToObject(Type, Int64)

将指定的 64 位有符号整数转换为枚举成员。

ToObject(Type, Object)

将具有整数值的指定对象转换为枚举成员。

ToObject(Type, SByte)

将指定的 8 位有符号整数值转换为枚举成员。

ToObject(Type, UInt16)

将指定的 16 位无符号整数值转换为枚举成员。

ToObject(Type, UInt32)

将指定的 32 位无符号整数值转换为枚举成员。

ToObject(Type, UInt64)

将指定的 64 位无符号整数值转换为枚举成员。

ToString()

将此实例的值转换为其等效的字符串表示形式。

ToString(IFormatProvider)
已过时.
已过时.

此方法重载已过时;请使用 ToString()

ToString(String)

使用指定格式将此实例的值转换成其等效的字符串表示。

ToString(String, IFormatProvider)
已过时.
已过时.

此方法重载已过时;请使用 ToString(String)

TryFormat<TEnum>(TEnum, Span<Char>, Int32, ReadOnlySpan<Char>)

尝试将枚举类型实例的值格式化为提供的字符范围。

TryParse(Type, ReadOnlySpan<Char>, Boolean, Object)

将一个或多个枚举常量的名称或数值的字符表示形式转换为等效的枚举对象。 一个参数指定该操作是否不区分大小写。

TryParse(Type, ReadOnlySpan<Char>, Object)

将一个或多个枚举常量的名称或数值的字符表示形式转换为等效的枚举对象。

TryParse(Type, String, Boolean, Object)

将一个或多个枚举常数的名称或数字值的字符串表示转换成等效的枚举对象。

TryParse(Type, String, Object)

将一个或多个枚举常数的名称或数字值的字符串表示转换成等效的枚举对象。

TryParse<TEnum>(ReadOnlySpan<Char>, Boolean, TEnum)

将一个或多个枚举常数的名称或数字值的字符串表示转换成等效的枚举对象。 一个参数指定该操作是否区分大小写。 用于指示转换是否成功的返回值。

TryParse<TEnum>(ReadOnlySpan<Char>, TEnum)

将一个或多个枚举常数的名称或数字值的字符串表示转换成等效的枚举对象。

TryParse<TEnum>(String, Boolean, TEnum)

将一个或多个枚举常数的名称或数字值的字符串表示转换成等效的枚举对象。 一个参数指定该操作是否区分大小写。 用于指示转换是否成功的返回值。

TryParse<TEnum>(String, TEnum)

将一个或多个枚举常数的名称或数字值的字符串表示转换成等效的枚举对象。 用于指示转换是否成功的返回值。

显式接口实现

IConvertible.GetTypeCode()

返回此 Enum 实例的类型代码。

IConvertible.ToBoolean(IFormatProvider)

根据基础类型将当前值转换为布尔值。

IConvertible.ToByte(IFormatProvider)

根据基础类型将当前值转换为 8 位无符号整数。

IConvertible.ToChar(IFormatProvider)

根据基础类型将当前值转换为 Unicode 字符。

IConvertible.ToDateTime(IFormatProvider)

根据基础类型将当前值转换为 DateTime

IConvertible.ToDecimal(IFormatProvider)

根据基础类型将当前值转换为 Decimal

IConvertible.ToDouble(IFormatProvider)

根据基础类型将当前值转换为双精度浮点数。

IConvertible.ToInt16(IFormatProvider)

根据基础类型将当前值转换为 16 位有符号整数。

IConvertible.ToInt32(IFormatProvider)

根据基础类型将当前值转换为 32 位有符号整数。

IConvertible.ToInt64(IFormatProvider)

根据基础类型将当前值转换为 64 位有符号整数。

IConvertible.ToSByte(IFormatProvider)

根据基础类型将当前值转换为 8 位有符号整数。

IConvertible.ToSingle(IFormatProvider)

根据基础类型将当前值转换为单精度浮点数。

IConvertible.ToString(IFormatProvider)
已过时.

此方法重载已过时;请改用 ToString()

IConvertible.ToType(Type, IFormatProvider)

根据基础类型将当前值转换为指定类型。

IConvertible.ToUInt16(IFormatProvider)

根据基础类型将当前值转换为 16 位无符号整数。

IConvertible.ToUInt32(IFormatProvider)

根据基础类型将当前值转换为 32 位无符号整数。

IConvertible.ToUInt64(IFormatProvider)

根据基础类型将当前值转换为 64 位无符号整数。

IFormattable.ToString(String, IFormatProvider)
已过时.

此方法重载已过时;请使用 ToString(String)

ISpanFormattable.TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

尝试将枚举的值格式化为提供的字符范围。

适用于

线程安全性

此类型是线程安全的。

另请参阅