not sure if this make sense at all im trying to understand how C# process the following logic
false && true || false
false || true && false
basically i'm trying to find out how C# evaluate these expression when there is no parentheses .
not sure if this make sense at all im trying to understand how C# process the following logic
false && true || false
false || true && false
basically i'm trying to find out how C# evaluate these expression when there is no parentheses .
The compiler figures it out because the standard specifies operator precedence.
That said, if an expression requires you to think for more than a second about what is happening in what sequence... use parentheses to make it clear =)
&&
has a higher precedence than||
so it's evaluated first. Effectively, they're equivalent to:If you're unsure, use the parentheses. They have no real negative impact and anything that makes code more readable is generally a good thing.
Perhaps a better example (so that the results are different) would have been: