Backend.Helper.Converter.ByteToHex C# (CSharp) Метод

ByteToHex() публичный статический Метод

method to convert a byte array into a hex string
public static ByteToHex ( byte comByte ) : string
comByte byte byte array to convert
Результат string
        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";
        }