ToString Method (Single)

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.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Public Shared Function ToString ( _
	value As Single _
) As String


Type: System.Single
A single-precision floating point number.

Return Value

Type: System.String
The String equivalent of the value of value.

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

      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

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft