字符串转成16进制数组

private static byte[] strToToHexByte(string hexString) //字符串转成16进制数组
{
hexString = hexString.Replace(" ", "");
if ((hexString.Length % 2) != 0)
hexString += " ";
byte[] returnBytes = new byte[hexString.Length / 2];
for (int i = 0; i < returnBytes.Length; i++)
returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
return returnBytes;
}

原文地址:https://www.cnblogs.com/shuenjian901/p/3386773.html