Class EnumConverter
Provides conversion between enum value and primitive types.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class EnumConverter
Methods
| Edit this page View SourceFromEnum<TEnum, TValue>(TEnum)
Converts enum value to numeric value.
Declaration
[CLSCompliant(false)]
public static TValue FromEnum<TEnum, TValue>(TEnum value) where TEnum : struct, Enum where TValue : unmanaged, INumberBase<TValue>, IConvertible
Parameters
Type | Name | Description |
---|---|---|
TEnum | value | The enum value to convert. |
Returns
Type | Description |
---|---|
TValue | The numeric equivalent of |
Type Parameters
Name | Description |
---|---|
TEnum | The type of the enum. |
TValue | The type of numeric value. |
GetTypeCode<TEnum>()
Gets underlying type of the enum.
Declaration
public static TypeCode GetTypeCode<TEnum>() where TEnum : struct, Enum
Returns
Type | Description |
---|---|
TypeCode | The underlying type of |
Type Parameters
Name | Description |
---|---|
TEnum | The type of the enum. |
Remarks
The call to this method can be effectively replaced with a constant by JIT.
ToEnum<TEnum, TValue>(TValue)
Converts a value of type TValue
to enum of type TEnum
.
Declaration
[CLSCompliant(false)]
public static TEnum ToEnum<TEnum, TValue>(TValue value) where TEnum : struct, Enum where TValue : unmanaged, INumberBase<TValue>, IConvertible
Parameters
Type | Name | Description |
---|---|---|
TValue | value | The value to be converted. |
Returns
Type | Description |
---|---|
TEnum | The enum value that is equivalent to |
Type Parameters
Name | Description |
---|---|
TEnum | The type of the enum. |
TValue | The numeric type representing enum value. |