Convert.ToString Method (Single)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Converts the value of the specified single-precision floating point number to its equivalent String representation.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
- Type: System.Single
A single-precision floating point number.
This implementation is identical to Single.ToString.
The following code sample illustrates the conversion of a Single to a String, using ToString.
Public Sub ConvertStringFloat(ByVal stringVal As String) Dim singleVal As Single = 0 Try singleVal = System.Convert.ToSingle(singleVal) outputBlock.Text &= String.Format("The string as a single is {0}.", _ singleVal) & vbCrLf Catch exception As System.OverflowException outputBlock.Text &= String.Format( _ "Overflow in string-to-single conversion.") & vbCrLf Catch exception As System.FormatException outputBlock.Text &= String.Format( _ "The string is not formatted as a Single.") & vbCrLf Catch exception As System.ArgumentException outputBlock.Text &= "The string is null." & vbCrLf End Try ' Single to string conversion will not overflow. stringVal = System.Convert.ToString(singleVal) outputBlock.Text &= String.Format("The single as a string is {0}.", _ stringVal) & vbCrLf End Sub
Show: