ByteArrayToHex
Converts a byte array to its hexadecimal string representation.
- Use
BitConverter.ToString()to convert thebytearray to a string. - Use
string.Replace()to remove dashes in the produced string.
public static partial class _30s
{
public static string ByteArrayToHex(byte[] bytes)
{
return BitConverter.ToString(bytes).Replace("-", "");
}
}byte[] data = { 241, 89, 54 };
_30s.ByteArrayToHex(data); // "F15936"