If I need to check multiple conditions, which is the preferred way with respect to performance
if( CND1 && CND2 && CND3 && CND4)
{
}
else
{
}
or
if(CND1)
{
if(CND2)
{
if(CND3)
{
if(CND4)
{
}
else
{
}
}
else
{
}
}
else
{
}
}
}
They will be identical in terms of performance, but the first form is much more readable IMO.
The only situation in which I’d split the conditions up would be if there were sets of logical conditions:
Although an alternative there which reads nicely (but does evaluate more conditions, admittedly) is: