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

  

上一篇:SQL重复记录查询-count与group by having结合查询重复记录


下一篇:详细分享UICollectionView的自定义布局(瀑布流, 线性, 圆形…)