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 .
&&
has a higher precedence than ||
so it's evaluated first. Effectively, they're equivalent to:
false && true || false => (false && true) || false => false
false || true && false => false || (true && false) => false
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:
true && false || false => (true && false) || false => false
true || false && false => true || (false && false) => true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With