Enum.TryParse<TEnum> Method (String, TEnum) |
Converts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object. 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,
out TEnum result
)
where TEnum : struct, new()
Parameters
- value
- Type: System.String
The string representation of the enumeration name or underlying value to convert. - 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