Short circuit on |= and &= assignment operators in C#

The C# specification guarantees that both sides are evaluated exactly once from left-to-right and that no short-circuiting occurs. General rules for expressions with embedded expressions The following rules apply to these kinds of expressions: parenthesized expressions (§7.6.3), element access expressions (§7.6.6), base access expressions with indexing (§7.6.8), increment and decrement expressions (§7.6.9, §7.7.5), cast … Read more

Is there actually a reason why overloaded && and || don’t short circuit?

All design processes result in compromises between mutually incompatible goals. Unfortunately, the design process for the overloaded && operator in C++ produced a confusing end result: that the very feature you want from && — its short-circuiting behavior — is omitted. The details of how that design process ended up in this unfortunate place, those … Read more

C++ short-circuiting of booleans

No, the B==2 part is not evaluated. This is called short-circuit evaluation. Edit: As Robert C. Cartaino rightly points out, if the logical operator is overloaded, short-circuit evaluation does not take place (that having been said, why someone would overload a logical operator is beyond me).