EnumTEnum Class

Generic helper class for the Enum class. Provides high performance solutions for already existing functionality in the Enum class along with some additional features.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.0.0
C#
public static class Enum<TEnum>
where TEnum : struct, new()
Inheritance
Object    EnumTEnum

Type Parameters

TEnum
The type of the enumeration. Must be an Enum type.

Remarks

Methods

AllFlagsDefined(TEnum) Gets whether every single bit value in flags are defined in the TEnum type, or, when flags is zero, it is checked whether zero is defined in TEnum.
AllFlagsDefined(Int64) Gets whether every single bit value in flags are defined in the TEnum type, or, when flags is zero, it is checked whether zero is defined in TEnum.
AllFlagsDefined(UInt64) Gets whether every single bit value in flags are defined in the TEnum type, or, when flags is zero, it is checked whether zero is defined in TEnum.
ClearCaches Clears caches associated with TEnum enumeration.
GetFlags Gets the defined flags in TEnum, where each flags are returned as distinct values.
GetFlags(TEnum, Boolean) Gets an IEnumerableT enumeration of flags, where each flags are returned as distinct values.
GetFlagsCount(TEnum) Gets the number of bits set in value. It is not checked, whether all flags are defined in TEnum.
GetFlagsCount(Int64) Gets the number of bits set in value or -1 if value does not fall into the range of TEnum. It is not checked, whether all flags are defined in TEnum.
GetFlagsCount(UInt64) Gets the number of bits set in value or -1 if value does not fall into the range of TEnum. It is not checked, whether all flags are defined in TEnum.
GetFlagsMask Gets a TEnum value where all defined single flag values are set.
GetName(TEnum) Retrieves the name of the constant in the specified enumeration that has the specified value.
GetName(Int64) Retrieves the name of the constant in the specified enumeration that has the specified value.
GetName(UInt64) Retrieves the name of the constant in the specified enumeration that has the specified value.
GetNames Retrieves the array of the values of the constants in enumeration TEnum.
GetValues Retrieves the array of the values of the constants in enumeration TEnum.
HasFlag(TEnum, TEnum) Gets whether the bits that are set in the flags parameter are set in the specified value.
HasFlag(TEnum, Int64) Gets whether the bits that are set in the flags parameter are set in the specified value.
HasFlag(TEnum, UInt64) Gets whether the bits that are set in the flags parameter are set in the specified value.
IsDefined(TEnum) Gets whether value is defined in TEnum.
IsDefined(Int64) Gets whether value is defined in TEnum as a field value.
IsDefined(ReadOnlySpanChar) Gets whether value is defined in TEnum.
IsDefined(String) Gets whether value is defined in TEnum.
IsDefined(StringSegment) Gets whether value is defined in TEnum.
IsDefined(UInt64) Gets whether value is defined in TEnum as a field value.
IsSingleFlag(TEnum) Gets whether only a single bit is set in value. It is not checked, whether this flag is defined in TEnum.
IsSingleFlag(Int64) Gets whether only a single bit is set in value. It is not checked, whether this flag is defined in TEnum.
IsSingleFlag(UInt64) Gets whether only a single bit is set in value. It is not checked, whether this flag is defined in TEnum.
Parse(ReadOnlySpanChar, Boolean) Converts the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object.
Parse(String, Boolean) Converts the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object.
Parse(StringSegment, Boolean) Converts the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object.
Parse(ReadOnlySpanChar, ReadOnlySpanChar, Boolean) Converts the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object.
Parse(String, String, Boolean) Converts the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object.
Parse(StringSegment, StringSegment, Boolean) Converts the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object.
ToString(TEnum) Returns the String representation of the given enum value specified in the value parameter.
ToString(TEnum, String) Returns the String representation of the given enum value specified in the value parameter.
ToString(TEnum, EnumFormattingOptions, String) Returns the String representation of the given enum value specified in the value parameter.
TryFormat(TEnum, SpanChar, Int32, ReadOnlySpanChar) Tries to format the value of the current TEnum instance into the provided span of characters using Auto formatting options.
TryFormat(TEnum, SpanChar, Int32, EnumFormattingOptions, ReadOnlySpanChar) Tries to format the value of the current TEnum instance into the provided span of characters.
TryParse(ReadOnlySpanChar, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.
TryParse(String, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.
TryParse(StringSegment, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.
TryParse(ReadOnlySpanChar, Boolean, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.
TryParse(ReadOnlySpanChar, ReadOnlySpanChar, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.
TryParse(String, Boolean, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.
TryParse(String, String, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.
TryParse(StringSegment, StringSegment, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.
TryParse(StringSegment, Boolean, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.
TryParse(ReadOnlySpanChar, ReadOnlySpanChar, Boolean, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.
TryParse(String, String, Boolean, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.
TryParse(StringSegment, StringSegment, Boolean, TEnum) Tries to convert the string representation of the name or numeric value of one or more enumerated values to an equivalent enumerated object. In case of success the return value is and parsed enum is returned in result parameter.

See Also