ChatHelper GetEnum TEnum, TUnderlayingType  Method Kentico 8.0 API Reference
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: 8.0.0.0 (8.0.5239.26125)

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

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