您的位置:首页 > 编程语言 > C#

c# 16进制显示转化

2016-07-04 20:22 531 查看
非原创。

接收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() + " ");
}));
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: