c# 16进制显示转化

非原创。

接收16进制数据,在TextBox委托显示:

 private void readPortandShow()
        {
            char[] HexChar = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
            byte receivebyte = (byte)serialPort1.ReadByte();
            char hexH = HexChar[receivebyte / 16];
            char hexL = HexChar[receivebyte % 16];
            this.tBox.Invoke(new MethodInvoker(delegate
                {
                    this.tBox.AppendText(hexH.ToString() + hexL.ToString() + " ");
                }));
        }

  

原文地址:https://www.cnblogs.com/studylyn/p/5641599.html