ToString Method (Byte)

Convert.ToString Method (Byte)

[ 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 8-bit unsigned integer to its equivalent String representation.

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

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

Parameters

value
Type: System.Byte
An 8-bit unsigned integer.

Return Value

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

This implementation is identical to Byte.ToString.

The following code sample illustrates the conversion of a Byte to a String, using ToString.


Public Sub ConvertStringByte(ByVal stringVal As String)
   Dim byteVal As Byte = 0

   Try
      byteVal = System.Convert.ToByte(stringVal)
      outputBlock.Text &= String.Format("{0} as a byte is: {1}", _
                                stringVal, byteVal) & vbCrLf
   Catch exception As System.OverflowException
      outputBlock.Text &= String.Format( _
          "Overflow in string-to-byte conversion.") & vbCrLf
   Catch exception As System.FormatException
      outputBlock.Text &= String.Format( _
          "The String is not formatted as a Byte.") & vbCrLf
   Catch exception As System.ArgumentException
      outputBlock.Text &= "The String is null." & vbCrLf
   End Try

   'The conversion from byte to string is always valid.
   stringVal = System.Convert.ToString(byteVal)
   outputBlock.Text &= String.Format("{0} as a string is {1}", _
                             byteVal, stringVal) & vbCrLf
End Sub


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft