Click or drag to resize
EnumTryParseTEnum Method (String, Boolean, TEnum)
Converts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object. A parameter specifies whether the operation is case-sensitive. The return value indicates whether the conversion succeeded.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static bool TryParse<TEnum>(
	string value,
	bool ignoreCase,
	out TEnum result
)
where TEnum : struct, new()

Parameters

value
Type: SystemString
The string representation of the enumeration name or underlying value to convert.
ignoreCase
Type: SystemBoolean
true to ignore case; false to consider case.
result
Type: TEnum
When this method returns, contains an object of type TEnum whose value is represented by value. This parameter is passed uninitialized.

Type Parameters

TEnum
The enumeration type to which to convert value.

Return Value

Type: Boolean
true if the value parameter was converted successfully; otherwise, false.
Exceptions
ExceptionCondition
ArgumentExceptionTEnum is not an enumeration type.
See Also