This method converts a String to a numeric value in the specified style using the formatting information.
[Visual Basic] Overloads Public Shared Function Parse( _ ByVal s As String, _ ByVal style As NumberStyles, _ ByVal info As NumberFormatInfo _ ) As Single [C#] public static float Parse( string s, NumberStyles style, NumberFormatInfo info ); [C++] public: static float Parse( String* s, NumberStyles style, NumberFormatInfo* info ); [JScript] public static function Parse( s : String, style : NumberStyles, info : NumberFormatInfo ) : float;
Returns a Single with the value represented by the string parameter.
Exception Type | Condition |
---|---|
ArgumentException | If the style is not a combination of bit flags from the NumberStyle enumeration. |
ArgumentNullException | If the string is a null reference (in Visual Basic Nothing). |
FormatException | If the sring is not of the correct format. |
OverflowException | If the string represents a number that is less than Single.MinValue or greater than Single.MaxValue. |
If s has been created by one of the Format methods using C, D, E, F, G, or N as the format specifier, it is guaranteed that s can be parsed when style is NumberStyles enumeration.
The Parse method does not throw a FormatException if the string is not a number (see NaN); it returns NaN instead. Nor does it throw an OverflowException; it returns PositiveInfinity, or NegativeInfinity if the number is too large or too small.
Single Structure | Single Members | System Namespace | Single.Parse Overload List | NumberStyles | CultureInfo | NumberFormatInfo | PositiveInfinity | NegativeInfinity | NaN | FromString | ToString