C# order of evaluation
Posted on 2009-02-17
In C++, two things are true about an expression such as
(a == b) || (c == d)
1) The order of evaluation is not guaranteed, (c == d) could be evaluated before (a == b)
(Section 5, paragraph 4 of the standard. "Except where noted, the order of evaluation (...words deleted...) is unspecified)
2) If either (a == b) or (c == d) is true, then expression evaluation is shortcut and the other comparison is not evaluated.
Section 8.5 of the ECMA-366 C# standard says "Except for the assignment operators, all binary operators are left-associative"
1) It looks to me as though (a == b) will always be evaluated first in C#. Am I missing anything?
2) If (a == b) is true, will C# evaluate (c == d)?