You cannot, because the logical closures of the operator I. In general, it is recommended to avoid side effects from such expressions, although there are quite acceptable applications (i.e if( someObj != null && someObj.Value == whatever ).. You can use the bitwise and operator ( &), which is not short-circuited, but again I would not do that.
You must first break these two method calls into variables, and then check if you need to do them.
bool first = SomeMethodCall();
bool second = SomeMethodThatMustExecute();
if( first && second )
{
}
Ed S. source
share