Converts a String to a float.
[Visual Basic] Public Shared Function FromString( _ ByVal s As String _ ) As Single [C#] public static float FromString( string s ); [C++] public: static float FromString( String* s ); [JScript] public static function FromString( s : String ) : float;
Returns the Single value of the string.
Exception Type | Condition |
---|---|
ArgumentException | If the string is a null reference (in Visual Basic Nothing). |
FormatException | If the string does not contain a real number. |
The default (locale-neutral) NumberFormatInfo is used. Use Parse and Format for locale dependent strings. (In addition see CultureInfo.)
The FromString 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.
The output from ToString should be consumable by FromString().
Single Structure | Single Members | System Namespace | Parse