Is there a built in way to convert a Byte Array to a Hex String or do I have to write my own?
Printable View
Is there a built in way to convert a Byte Array to a Hex String or do I have to write my own?
Depending on the type of string encoding you want to use, you can use a member of the System.Text namespace to do your encoding. You can use a UTF7Encoding for Unicode strings, or the AsciiEncoding for Ascii strings.
Here is a simple ascii example:
vb Code:
Dim objByte As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes("MyString") MessageBox.Show(System.Text.ASCIIEncoding.ASCII.GetString(objByte))
EDIT: Oops I read that wrong, you wanted a byte array to a hex string, not a normal string. Let me see what else I can find.
To output it as a hex string, you can use the Bitconverter:
vb Code:
MessageBox.Show(BitConverter.ToString(objByte))