110,536
社区成员
发帖
与我相关
我的任务
分享
byte[] buf16 = buf.Split(' ').Select(s=>Convert.ToByte(s)).ToArray();
buf.Split(' ').Select(s=>Convert.ToByte(s)).ToArray()
byte[] buf16 = Encoding.ASCII.GetBytes(buf);
private byte[] StringToBytes16(string source)
{
byte[] destination = new byte[source.Length / 2];
for (int i = 0, j = 0; i < source.Length && j < source.Length / 2; i += 2, j++)
{
string item = source.Substring(i, 2);
destination[j] = Convert.ToByte(item, 16);
}
return destination;
}