The built-in &&
operator always evaluates its left operand first. For example:
if (a && b)
{
//block of code
}
If a
is false
, then b
will not be evaluated.
If you want b
to be evaluated first, and a
only if b
is true, simply write the expression the other way around:
if (b && a)
{
//block of code
}