This documentation is archived and is not being maintained.

Convert.ToString Method (Byte)

.NET Framework 1.1

Converts the value of the specified 8-bit unsigned integer to its equivalent String representation.

[Visual Basic]
Overloads Public Shared Function ToString( _
   ByVal value As Byte _
) As String
public static string ToString(
 byte value
public: static String* ToString(
 unsigned char value
public static function ToString(
   value : Byte
) : String;


An 8-bit unsigned integer.

Return Value

The String equivalent of the value of value.


This implementation is identical to Byte.ToString.


[Visual Basic, C#, C++] The following code sample illustrates the conversion of a Byte to a String, using ToString.

[Visual Basic] 
Public Sub ConvertStringByte(ByVal stringVal As String)
    Dim byteVal As Byte = 0

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

    'The conversion from byte to string is always valid.
    stringVal = System.Convert.ToString(byteVal)
    System.Console.WriteLine("{0} as a string is {1}", _
                              byteVal, stringVal)
End Sub

public void ConvertStringByte(string stringVal) {
    byte byteVal = 0;
    try {
        byteVal = System.Convert.ToByte(stringVal);
        System.Console.WriteLine("{0} as a byte is: {1}",
            stringVal, byteVal);
    catch (System.OverflowException) {
            "Conversion from string to byte overflowed.");
    catch (System.FormatException) {
            "The string is not formatted as a byte.");
    catch (System.ArgumentNullException) {
            "The string is null.");
    //The conversion from byte to string is always valid.
    stringVal = System.Convert.ToString(byteVal);
    System.Console.WriteLine("{0} as a string is {1}",
        byteVal, stringVal);


   void ConvertStringByte(String* stringVal)
      Byte byteVal = 0;

      try {
         byteVal = System::Convert::ToByte(stringVal);
         System::Console::WriteLine(S" {0} as a Byte is: {1}",
            stringVal, __box(byteVal));
      } catch (System::OverflowException*) {
         System::Console::WriteLine(S"Conversion from String* to Byte overflowed.");
      } catch (System::FormatException*) {
         System::Console::WriteLine(S"The String* is not formatted as a Byte.");
      } catch (System::ArgumentNullException*) {
         System::Console::WriteLine(S"The String* is 0.");

      //The conversion from Byte to String* is always valid.
      stringVal = System::Convert::ToString(byteVal);
      System::Console::WriteLine(S" {0} as a String* is {1}",
         __box(byteVal), stringVal);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Convert Class | Convert Members | System Namespace | Convert.ToString Overload List