Show / Hide Table of Contents

Class EnumConverter

Provides conversion between enum value and primitive types.

Inheritance
object
EnumConverter
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class EnumConverter

Methods

| Edit this page View Source

FromEnum<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 value.

Type Parameters
Name Description
TEnum

The type of the enum.

TValue

The type of numeric value.

| Edit this page View Source

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 TEnum.

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.

| Edit this page View Source

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 TEnum.

Type Parameters
Name Description
TEnum

The type of the enum.

TValue

The numeric type representing enum value.

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾