5
Questa è una domanda simile a this one here.Funzione incorporata per la conversione da byte a stringa esadecimale
Esiste un metodo incorporato che converte un array di byte in stringa esadecimale? In particolare, sto cercando un costruito in funzione per la
/// <summary>
/// Convert bytes in a array Bytes to string in hexadecimal format
/// </summary>
/// <param name="Bytes">Bytes array</param>
/// <param name="Length">Total byte to convert</param>
/// <returns></returns>
public static string ByteToHexString(byte[] Bytes, int Length)
{
Debug.Assert(Length <= Bytes.GetLength(0));
StringBuilder hexstr = new StringBuilder();
for (int i = 0; i < Length; i++)
{
hexstr.AppendFormat("{0,02:X}", Bytes[i]);
}
hexstr.Replace(' ', '0'); //padd empty space to zero
return hexstr.ToString();
}
+1 scritto questo codice esatto di un paio di settimane fa ... –