取出一个字节(byte)中的每一位(bit)

例:

byte byZT = 0x36;

int n0, n1, n2, n3, n4, n5, n6, n7;

n0 = (byZT & 0x01) == 0x01 ? 1 : 0;

 if (n0 == 0) 

{

textBox50.Text = "正常";

else

{

 textBox50.Text = "异常";

}

n1 = (byZT & 0x02) == 0x02 ? 1 : 0;
n2 = (byZT & 0x04) == 0x04 ? 1 : 0;
n3 = (byZT & 0x08) == 0x08 ? 1 : 0;
n4 = (byZT & 0x10) == 0x10 ? 1 : 0;
n5 = (byZT & 0x20) == 0x20 ? 1 : 0;
n6 = (byZT & 0x40) == 0x40 ? 1 : 0;
n7 = (byZT & 0x80) == 0x80 ? 1 : 0;

你可能感兴趣的:(C#,MFC,类型解析,类型转换,C++)