日期:2014-05-18  浏览次数:20949 次

周末加班提问的您就帮一帮把
是这样的,int [] arl="68 02 31 94 11 00 00 68 11 04 33 32 34 33 89 16",注意这里面的数字全是16进制,

 for (int x = 0; x < arl.Count; x++)
  {
  int r;

  r = check(arl[x].ToString());------这是对字符串进行一定判断,和我问的没关系
  if (r == 0)
  {
  Ok++;
  }
  else
  {
  Bad++;
   
  richTextBox1.Text += arl[x].ToString() + "\r\n";
  //richTextBox1.SelectionColor = Color.Red;
  //richTextBox1.Text = "int i = 40;";
  richTextBox1.Select(0, arl[x].ToString().Length);
  richTextBox1.SelectionColor = Color.Red;
  }


现在我想在else里对arl[8]的二进制最高位是不是1进行判断,例如上面的11就是00010001,就是对这判断,16进制转二进制,类型还有差别,糊涂了,大神指教吧!

------解决方案--------------------
var s = "68 02 31 94 11 00 00 68 11 04 33 32 34 33 89 16".Split(' ').Where(t => t.Trim() != "").ToList();
var source = (from temp in s select new { shiliu = temp, er = Convert.ToString(Convert.ToInt32(temp) / 10 * 16 + Convert.ToInt32(temp) % 10, 2) }).Where(t => t.er[0] == '1').ToArray();
foreach (var tempsoruce in source)
Console.WriteLine(tempsoruce.shiliu + " " + tempsoruce.er);