StringExtensions.AsFloat Method

Include Protected Members
Include Inherited Members

Converts a string to a Single number.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

Overload List

  Name Description
Public methodStatic member AsFloat(String) Converts a string to a Single number.
Public methodStatic member AsFloat(String, Single) Converts a string to a Single number and specifies a default value.

Top

Remarks

The floating-point (Single) data type is useful for calculations that involve numbers too large to be represented as integers. Floating-point numbers are often expressed in exponential form (for example, 2.5e15), and can also be fractional or decimal numbers (in contrast to whole numbers). A number of this type can be precise (for rounding purposes) up to 7 digits.

Using the AsFloat methods, you can only convert a numeric value in string format to a Single value. Before you try to convert, you can check whether the string can be converted to this type by calling the IsFloat(String) method, which returns true if the string value can be converted.

See Also

Reference

StringExtensions Class

System.Web.WebPages Namespace