For the following If-statements in VB.NET, what will be the sequence in which the conditions will be evaluated?
Case 1:
If ( condition1 AND condition2 AND condition3 ) . . End If
Case 2:
If ( condition1 OR condition2 OR condition3 ) . . End If
Case 3:
If ( condition1 OR condition2 AND condition3 OR condition4) . . End If
VB.NET is a very strange beast from the C-programmer standpoint. As Gerrie mentioned in a different answer, all three conditions are evaluated in their full entirety without short-circuiting. AndAlso and OrElse can save your day if that’s what you want.
As for the last if, the order of evaluation is as follows:
As a rule of thumb: if there’s any ambiguitiy, use brackets to specify order of evaluation explicitly.