Example
[Visual Basic, C #] The following example illustrates the use of byte an array to a hexadecimal value string byte.
[Visual Basic]
Class HEXTEST
Private shared hexdigits as char () = {"0" C, "1" C, "2" C, "3" C, "4" C, "5" C, "6" C, "7" C, " 8 "C," 9 "C," A "C," B "C," C "C," D "C," E "C," F "C}
Public Shared Function tohexString (bytes () as Byte) AS String
Dim HexStr As String = ""
DIM I as integer
For i = 0 to bytes.length - 1
HEXSTR = HEXSTR HEX (Bytes (i))
Next i
Return HEXSTR
End function 'tohexstring
Shang Sub Main ()
Dim b as byte () = {& H0, & H12, & H34, & H56, & HAA, & H55, & HFF}
Console.writeLine (tohexstring (b))
End Sub 'Main
End Class' HEXTEST
[C #]
Class HEXTEST
{
Static char [] hexdigits = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
Public static string tohexstring (byte [] Bytes) {
Char [] chars = new char [bytes.length * 2];
For (int i = 0; i INT b = bytes [i]; Chars [i * 2] = HEXDIGITS [B >> 4]; Chars [i * 2 1] = HEXDIGITS [B & 0xF]; } Return New String (Chars); } Static void main () { Byte [] b = {0x00, 0x12, 0x34, 0x56, 0xaa, 0x55, 0xFF}; Console.writeline (tohexstring (b)); } }