EnumExtensions Class

Provides extension methods for the Enum type.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0-preview.1
C#
public static class EnumExtensions
Inheritance
Object    EnumExtensions

Methods

AllFlagsDefined(Enum) Gets whether every single bit value in flags are defined in the enum type of flags, or when flags is zero, it is checked whether zero is defined in the enum type of flags.
AllFlagsDefinedTEnum(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.
GetDefinedOrDefaultTEnum Returns value if it is defined in TEnum; otherwise, returns defaultValue, even if it is undefined.
GetDefinedOrNullTEnum Returns value if it is defined in TEnum; otherwise, returns .
GetFlagsTEnum Gets an IEnumerableT enumeration of flags, where each flags are returned as distinct values.
GetFlagsCountTEnum Gets the number of bits set in value. It is not checked, whether all flags are defined in TEnum.
GetNameTEnum Retrieves the name of the constant in the specified enumeration that has the specified value.
HasFlagTEnum Gets whether the bits that are set in the flags parameter are set in the specified value.
IsDefinedTEnum Gets whether value is defined in TEnum.
IsSingleFlag(Enum) Gets whether only a single bit is set in value.
IsSingleFlagTEnum(TEnum) Gets whether only a single bit is set in value. It is not checked, whether this flag is defined in TEnum.
ToStringTEnum(TEnum, String) Returns the String representation of the given enum value.
ToStringTEnum(TEnum, EnumFormattingOptions, String) Returns the String representation of the given enum value specified in the value parameter.

See Also