在C#中怎么判断这个bool值的真假的

private bool[,]struArr=new bool[5,5]; int xpos = e.X / 31;
int ypos = e.Y / 31;
struArr[xpos, ypos] = !struArr[xpos, ypos];
bool b = struArr[xpos, ypos]; struArr[xpos, ypos] = !struArr[xpos, ypos];这句什么意思?这小段代码怎么判断BOOL的真假的啊 谢谢

我来补充一下执着的回答这里牵涉到运算符的运算顺序问题‘!’运算符的优先级大于‘=’的优先级所以struArr[xpos, ypos] = !struArr[xpos, ypos];这句代码假如struArr[xpos, ypos]的值为False,那么经过‘!’运算以后 struArr[xpos, ypos]的值就变为True了这句代码就相当于struArr[xpos, ypos] = True
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-06-07
struArr[xpos, ypos] = !struArr[xpos, ypos];这句代码的意思是:把数据StruArr第xpos行,第ypos列的当前值改为相反值,比如原来为False,那么通过这句代码就为True 。
第2个回答  2013-06-07
放在If()括号中就可以!

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网