This method converts a String to a numeric value.
[Visual Basic] Overloads Public Shared Function Parse( _ ByVal s As String, _ ByVal style As NumberStyles _ ) As Single [C#] public static float Parse( string s, NumberStyles style ); [C++] public: static float Parse( String* s, NumberStyles style ); [JScript] public static function Parse( s : String, style : NumberStyles ) : float;
A Single value represented by the string parameter.
Exception Type | Condition |
---|---|
ArgumentNullException | If the string is a null reference (in Visual Basic Nothing). |
ArgumentException | If the style is not a combination of bit flags from the NumberStyles enumeration. |
FormatException | If the string is not the correct format. |
OverflowException | If the string represents a number that is less than Single.MinValue or greater than Single.MaxValue. |
The numeric format information is obtained from the current locale.
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