Single.Parse Method (String)
Converts the string representation of a number to its single-precision floating-point number equivalent.
Assembly: mscorlib (in mscorlib.dll)
Elements in square brackets ([ and ]) are optional. The following table describes each element.
A series of white space characters.
A negative sign symbol or a positive sign symbol. Valid sign characters are determined by the NumberFormatInfo.NegativeSign and NumberFormatInfo.PositiveSign properties of the current culture. Only a leading sign can be used.
A series of digits ranging from 0 to 9 that specify the integral part of the number. Runs of integral-digits can be partitioned by a group-separator symbol. For example, in some cultures a comma (,) separates groups of thousands. The integral-digits element can be absent if the string contains the fractional-digits element.
A culture-specific thousands separator symbol.
A culture-specific decimal point symbol.
A series of digits ranging from 0 to 9 that specify the fractional part of the number.
The "e" or "E" character, which indicates that the value is represented in exponential (scientific) notation.
A series of digits ranging from 0 to 9 that specify an exponent.
The s parameter is interpreted using a combination of the NumberStyles.Float and NumberStyles.AllowThousands flags. This means that white space and thousands separators are allowed but currency symbols are not. To explicitly define the elements (such as currency symbols, thousands separators, and white space) that can be present in s, use the Parse(String, NumberStyles) method overload.
The s parameter is parsed by using the formatting information in a NumberFormatInfo object that is initialized for the current system culture. For more information, see CurrentInfo. To parse a string by using the formatting information of a specific culture, use the Parse(String, IFormatProvider) or Parse(String, NumberStyles, IFormatProvider) method.
Ordinarily, if you pass the Parse method a string that is created by calling the ToString method, the original Single value is returned. However, because of a loss of precision, the values may not be equal.
If a separator is encountered in the s parameter during a parse operation, and the applicable currency or number decimal and group separators are the same, the parse operation assumes that the separator is a decimal separator rather than a group separator. For more information about separators, see CurrencyDecimalSeparator, NumberDecimalSeparator, CurrencyGroupSeparator, and NumberGroupSeparator.
Available since 8
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1