共用方式為


Byte.ToString Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Converts the value of the current Byte object to its equivalent string representation.

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

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Overrides Function ToString As String
[SecuritySafeCriticalAttribute]
public override string ToString()

Return Value

Type: System.String
The string representation of the value of this object, which consists of a sequence of digits that range from 0 to 9 with no leading zeroes.

Remarks

The return value is formatted with the general numeric format specifier ("G") and the NumberFormatInfo object for the thread current culture. To define the formatting of the Byte value's string representation, call the ToString method. To define both the format specifiers and culture used to create the string representation of a Byte value, call the ToString method.

The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

For information about the thread current culture, see Thread.CurrentCulture.

Examples

The following example uses the ToString() method to display an array of byte values to the console.

Dim bytes() As Byte = {0, 1, 14, 168, 255}
For Each byteValue As Byte In bytes
   outputBlock.Text &= byteValue.ToString() & vbCrLf
Next
' The example displays the following output if the current
' culture is en-US:
'       0
'       1
'       14
'       168
'       255      
byte[] bytes = { 0, 1, 14, 168, 255 };
foreach (byte byteValue in bytes)
   outputBlock.Text += byteValue + "\n";
// The example displays the following output if the current
// culture is en-US:
//       0
//       1
//       14
//       168
//       255

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.