首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

OutPutStr解决办法

2012-09-27 
OutPutStrprivate void BtGetVersion_Click(object sender, EventArgs e){if (!bEanble || bThread)//Eanb

OutPutStr
private void BtGetVersion_Click(object sender, EventArgs e)
  {
  if (!bEanble || bThread) // Eanble =true bThread =false
  return;

  byte[] bSerial = new byte[6];
  byte[] bVersion = new byte[1];

  if (Public.RmuGetVersion(phCom, bSerial, bVersion, pflag))
  {
  MessageBox.Show("硬件版本号:" + Public.HexByteToString(bSerial, 6) + "\n" + "软件版本号:v" + Convert.ToString(bVersion[0] >> 4) + "." + Convert.ToString(bVersion[0] & 0x0F));
  }
  else
  MessageBox.Show("读取版本信息失败");
  }


  public static string HexByteToString(byte[] InPutByte, int ConvertLen)
  {
  string OutPutStr = "";
  try
  {
  for (int i = 0; i < ConvertLen; i++)
  {
  OutPutStr += Convert.ToString((InPutByte[i] >> 4), 16);
  OutPutStr += Convert.ToString((InPutByte[i] & 0x0F), 16);
  }
  return OutPutStr;// 真心不懂、这个OutPutStr的输出怎么来的,为什么?麻烦高手给讲解下。越详细越好
  }
  catch (Exception)
  {
  return "";
  }
  }


[解决办法]
根据InPutByte传入的数组的数据,对每一位先向右移动4位得到一个十六进制值,再and十六进制的0f得到一个十六进制的值,最后把这些都拼起来,得到OutPutStr。
[解决办法]
那么还是0。
>>4相当于除以16

热点排行