Converts a string to an enumerated value.
[Visual Basic] Overloads Public Shared Function FromString( _ ByVal enumType As Type, _ ByVal value As String, _ ByVal ignoreCase As Boolean _ ) As Object [C#] public static object FromString( Type enumType, string value, bool ignoreCase ); [C++] public: static Object* FromString( Type* enumType, String* value, bool ignoreCase ); [JScript] public static function FromString( enumType : Type, value : String, ignoreCase : Boolean ) : Object;
The enumerated value as an object.
Exception Type | Condition |
---|---|
ArgumentNullException | The enumType or value parameter is a null reference (in Visual Basic Nothing). |
ArgumentException | The enumType parameter is not an Enum type.
The string does not correspond to a valid value of the enumeration. |
Given the string representation of an enumerated name (ie "Red", "Green | Blue"), or value ("1", "12") returns the enumerated value as an object. Case sensitive by default, but if ignoreCase is true, this accepts strings of the form "green" as well.
Enum Class | Enum Members | System Namespace | Enum.FromString Overload List