Imports System
Imports System.Text
Public Class Program
Public Shared Function ByteArrayToString(ByVal ba As Byte()) As String
Dim hex As StringBuilder = New StringBuilder(ba.Length * 2)
For Each b As Byte In ba
hex.AppendFormat("{0:X2} ", b)
Next
Return hex.ToString()
End Function
Public Shared Sub Main()
Dim bytes As Byte() = {0, 1, 2, 3, 4, 5, 10, 20, 254, 255}
Dim hexString As String = ByteArrayToString(bytes)
Console.WriteLine(hexString)
End Sub
End Class
' run:
'
' 00 01 02 03 04 05 0A 14 FE FF
'