Click or drag to resize
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: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
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: Boolean
true if the value parameter was converted successfully; otherwise, false.
Exceptions
ExceptionCondition
ArgumentExceptionTEnum is not an enumeration type.
See Also