///
/// 16进制字符串转换成字节数组
///
///
///
public static byte[] HexStringToByteArray(string s)
{
s = s.Replace(" ", "");
byte[] buffer = new byte[s.Length / 2];
for (int i = 0; i < s.Length; i += 2)
{
buffer[i / 2] = (byte)Convert.ToByte(s.Substring(i, 2), 16);
}
return buffer;
}
字节数组就是字节数组,没有十六进制字节数组这种叫法,十六进制统一叫做十六进制字符串。
string str = "00 B1 01 001A 53FC337C 00 008C 012C";
string[] strs = str.Split(' ');
byte[] result = new byte[strs.Length];
for (int i = 0; i < strs.Length; i++)
{
result[i] = (byte)Convert.ToInt32(strs[i], 16);
}
看看我还能正常回复吗?