If you want to some code to execute based on two or more conditions which is the best way to format that if statement ?
first example:-
if(ConditionOne && ConditionTwo && ConditionThree)
{
Code to execute
}
Second example:-
if(ConditionOne)
{
if(ConditionTwo )
{
if(ConditionThree)
{
Code to execute
}
}
}
which is easiest to understand and read bearing in mind that each condition may be a long function name or something.
Best Solution
I prefer Option A
If you do have particularly long variables/method conditions you can just line break them
If they're even more complicated, then I'd consider doing the condition methods separately outside the if statement
IMHO The only reason for option 'B' would be if you have separate
else
functions to run for each condition.e.g.