Imports System
Imports System.Text
Imports System.Linq
Public Class Program
Public Shared Sub PrintByteArray(ByVal bytes As Byte())
Dim sb = New StringBuilder("byte[] = ")
For Each b In bytes
sb.Append(b & ", ")
Next
Console.WriteLine(sb.ToString())
End Sub
Public Shared Function HexStringToByteArray(ByVal hex As String) As Byte()
hex = If(hex.Length Mod 2 = 1, "0" & hex, hex)
Return Enumerable.Range(0, hex.Length).Where(Function(x) x Mod 2 = 0).Select(Function(x) Convert.ToByte(hex.Substring(x, 2), 16)).ToArray()
End Function
Public Shared Sub Main(ByVal args As String())
Dim barr As Byte() = HexStringToByteArray("1B6E2AC")
PrintByteArray(barr)
End Sub
End Class
' run:
'
' byte[] = 1, 182, 226, 172,
'