Click or drag to resize

ExtensionsReflectionGetValueTEnum Method

Returns the enum value from a display name. The enum members requires the DisplayNameAttribute. If non of the enum values has a matching DisplayName, then it will try to use TryParseTEnum(String, TEnum) to retrive a value; otherwise it will return the default value.

Returns the default value of the enum if value is null

Namespace:  Cauldron
Assembly:  Cauldron.Activator (in Cauldron.Activator.dll) Version: 3.2.0.2
Syntax
public static TEnum GetValue<TEnum>(
	this string value
)
where TEnum : struct, new(), IConvertible

Parameters

value
Type: SystemString
The value that corresponeds with the enum's DisplayName

Type Parameters

TEnum
The enum type to parse into

Return Value

Type: TEnum
The associated enum value of value

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also