将16进制字符串转换成16进制数据

var tb1 = Tb1.Text;
            if (string.IsNullOrEmpty(tb1))
            {
                tb1 = "0000";
            }
            var s1 = tb1.Substring(0, 2);
            var int_1 = Convert.ToInt32(s1, 16);
            var s2 = tb1.Substring(2, 2);
            var int_2 = Convert.ToInt32(s2, 16);
            var bt1 = Convert.ToByte(int_1);
            var bt2 = Convert.ToByte(int_2);
            var bt = new byte[] { 0xfc, 0x07, bt1, bt2 };
            var vCrc = CrcCcitt.Crc(bt);
            tb_status.Text += "Disable Set --->" + Environment.NewLine;
            tb_status.Text += "[";
            foreach (var b in vCrc)
            {
                tb_status.Text += Convert.ToString(b, 16) + " ";
            }
            tb_status.Text += "]" + Environment.NewLine;
            var data = _intoNotes.SettingCommand(vCrc);
            tb_status.Text += data + Environment.NewLine;
posted @ 2014-05-30 10:42  Seaurl  阅读(1534)  评论(0编辑  收藏  举报