C#//字节数组转16进制字符串

//字节数组转16进制字符串
private static string byteToHexStr(byte[] bytes,int length)
{
string returnStr = "";
if (bytes != null)
{
for (int i = 0; i < length; i++)
{
returnStr += bytes[i].ToString("X2");
}
}
return returnStr;
}

也可以

BitConverter.ToString(buffer)一句话就搞定了。
JAVA&NET技术QQ群号:456257217有问题的可以在群里面提问。
原文地址:https://www.cnblogs.com/shiyh/p/15797496.html