Nested If or single if with And operator, which is better approach?
Single If with And
if (txtPackage.Text != string.Empty && txtPackage.Text == 'abc') { // }
Nested If
if (txtPackage.Text != string.Empty) { if (txtPackage.Text == 'abc') { // } }
Are you going to do something different in the ‘nested if’ example if, in fact, txtPackage.Text isn’t empty but contains something other than ‘abc’?
If you aren’t, I’d ask why are you checking for string.empty at all?
You could just write:
and be done with it.
Totally depends upon what you want to do in the end.