Click or drag to resize
EnumStringRepresentationExtensionsToEnumTEnum Method
Converts the string representation of the enum value to the actual enum value.

Namespace: CMS.Helpers
Assembly: CMS.Helpers (in CMS.Helpers.dll) Version: 10.0.0
Syntax
C#
public static TEnum ToEnum<TEnum>(
	this string stringRepresentation
)
where TEnum : struct, new(), IConvertible, IComparable, IFormattable

Parameters

stringRepresentation
Type: SystemString
String representation of the enum value

Type Parameters

TEnum
Enum type

Return Value

Type: TEnum
Returns the enum value if it is specified using the EnumStringRepresentationAttribute. Otherwise returns the default enum 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