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: SystemAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax 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:
Booleantrue if the
value parameter was converted successfully; otherwise, false.
Exceptions See Also