Click or drag to resize

StringExtensionsToEnumTEnum Method (String)

[This is preliminary documentation and is subject to change.]

Converts a string to an enum. When converting fails, throws an exception

Namespace:  CSInfrastructure.Extensions
Assembly:  CSInfrastructure (in CSInfrastructure.dll) Version: 1.13.0+Branch.master.Sha.d583fc64569355d188a9c0818d257b6d0d3e1339
Syntax
C#
public static TEnum ToEnum<TEnum>(
	this string value
)
where TEnum : struct, new()

Parameters

value
Type: SystemString
The string to convert

Type Parameters

TEnum
The type of enum to convert to

Return Value

Type: TEnum
An 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).
Exceptions
ExceptionCondition
ArgumentExceptionThrow when value is not a valid enum value
ArgumentNullExceptionThrow when value is NULL
Remarks
https://stackoverflow.com/questions/16100/how-should-i-convert-a-string-to-an-enum-in-c
See Also