日期:2014-05-17  浏览次数:20896 次

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