Click or drag to resize

Utils_StringTryConvertToEnumT Method (String, Boolean)

Tries to obtain an enum value from a matching text.

Namespace:  MicaSystems.Utils
Assembly:  MicaSystems.Utils (in MicaSystems.Utils.dll) Version: 1.0.0.0 (1.1.0.123)
Syntax
C#
public static Nullable<T> TryConvertToEnum<T>(
	this string text,
	bool ignoreCase
)
where T : struct, new(), IConvertible

Parameters

text
Type: SystemString
A text representing an enum value.
ignoreCase
Type: SystemBoolean
If set to true ignore case.

Type Parameters

T

Return Value

Type: NullableT
The corresponding enum value if found, null otherwise.

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