C# BitConverter ToString(Byte[])
Description
BitConverter ToString(Byte[])
converts the numeric
value of each element of a specified array of bytes to its equivalent hexadecimal
string representation.
Syntax
BitConverter.ToString(Byte[])
has the following syntax.
public static string ToString(
byte[] value
)
Parameters
BitConverter.ToString(Byte[])
has the following parameters.
value
- An array of bytes.
Returns
BitConverter.ToString(Byte[])
method returns A string of hexadecimal pairs separated by hyphens, where each pair represents
the corresponding element in value; for example, "7F-2C-4A-00".
Example
The following code example converts Byte arrays to String objects with the ToString method.
using System;/*from ww w . j a v a 2 s .c o m*/
class BytesToStringDemo
{
public static void Main( )
{
byte[ ] bytes = {
0, 1, 2, 4, 8, 16, 32, 64, 128, 255 };
Console.WriteLine( BitConverter.ToString( bytes ) );
}
}
The code above generates the following result.