5
Ceci est une question similaire à this one here.Fonction intégrée de conversion de chaîne octet à chaîne hexadécimale
Existe-t-il une méthode intégrée qui convertit un tableau d'octets en chaîne hexadécimale? Plus précisément, je suis à la recherche d'une fonction intégrée pour
/// <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 Wrote ce code exact il y a deux semaines ... –