Jun 13, 2009

C# short-circuit logical operators

"&&" and "||" operators use short-circuit. Thus,

if (false && expr1)
{
// Won't evaluate expr1
}

Or

if (true || expr2)
{
// Won't evaluate expr2
}

If you want both sides to be evaluated use the "&" and "|" operators

No comments:

Post a Comment