c# - Why obvious False result of logical AND operation cancels out FOR loop iteration -


my question why condition in for loop makes cancel out iteration, seems me condition fulfilled?! if try 1 of 2 given variables without using , operator looping works , continues infinitely.

bool = false; bool b = false; (; && b == false; ) {     console.writeline(""); } 

this condition

a && b == false 

means

a && (b == false) 

since && short circuit evaluation, first false result in false whole expression, , there no need evaluate second expression.

also add, single & (which doesn't perform short circuit evaluation, complete condition result in false.

if want compare both a , b false can do:

a == false && b == false 

or

!a && !b 

you should consider using while loop, if there no iteration variable involved.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -