Convert.ToString Method (Single)

July 28, 2014

Converts the value of the specified single-precision floating point number to its equivalent String representation.

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

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

Parameters

value
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

   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


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft