public static string ByteToHex(byte[] comByte)
{
if (comByte.Length >= 1)
{
//create a new StringBuilder object
var builder = new StringBuilder(comByte.Length * 3);
//loop through each byte in the array
foreach (byte data in comByte)
//convert the byte to a string and add to the stringbuilder
builder.Append(Convert.ToString(data, 16).PadLeft(2, '0').PadRight(3, ' '));
//remove last ' '
builder.Remove(builder.Length - 1, 1);
//return the converted value
return builder.ToString().ToUpper();
}
return "ByteArray is Empty";
//return "00";
}