Click or drag to resize
ChatHelperGetEnumInternalTEnum, TUnderlayingType Method
Gets Enum from its underlying type. If the specified value doesn't have its representation in the enum, defaultValue is returned. Exception is thrown if TEnum is not Enum.

Namespace: CMS.Chat
Assembly: CMS.Chat (in CMS.Chat.dll) Version: 10.0.0
Syntax
C#
protected virtual TEnum GetEnumInternal<TEnum, TUnderlayingType>(
	TUnderlayingType value,
	TEnum defaultValue
)
where TEnum : struct, new(), IConvertible
where TUnderlayingType : struct, new()

Parameters

value
Type: TUnderlayingType
Value of an enum
defaultValue
Type: TEnum
Default value wich will be returned if value is not found within an enum

Type Parameters

TEnum
Enum type
TUnderlayingType
Type of underyling field of an enum (can be any integral type except char)

Return Value

Type: TEnum
Enum element or defaultValue
Examples
enum Days { Saturday = 3, Sunday = 4, Monday = 5, Tuesday = 6, Wednesday = 7, Thursday = 8, Friday = 9}; Days day = GetEnum(5, Days.Saturday); // returns Days.Monday Days day = GetEnum(1, Days.Saturday); // returns Days.Saturday, (Days)1 would return 1
See Also