字符串转十六进制数组

举个例子:

字符串:str_Command=“01 06 10 00 00 00 8D 07”

转为8位字节数组:

string[] strs = str_Command.Split(' ');
byte[] bts = new byte[strs.Length];

for (int i = 0; i < strs.Length; i++)
{
bts[i] = byte.Parse(strs[i], System.Globalization.NumberStyles.HexNumber);
}

//思路:

1.字符串转字符串数组,

2.遍历字符串数组,通过Byte.Parse(),获取字节数组。

 

posted @   冲云霄  阅读(346)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示