I think you're basically asking whether the &&
short-circuits. It does - if the firstoperand evaluates to false
, the second operand isn't evaluated. This is guaranteed by the language specification. From section 7.12 of the C# 5 specification:
The
&&
and||
operators are conditional versions of the&
and|
operators:
- The operation
x && y
corresponds to the operationx & y
, except thaty
is evaluated only ifx
is notfalse
.- The operation
x || y
corresponds to the operationx | y
, except thaty
is evaluated only ifx
is nottrue
.
(I included the section about ||
for completeness.)