How do these practically differ?
// Approach one
if (x == 1)
DoSomething();
else if (x == 2)
DoSomethingElse();
// Approach two
if (x == 1)
DoSo
When you use else statement, only one of the branches will be run (i.e. the first, which meets the if condition). All other if conditions won't even be estimated:
// approach one
int x = 1;
if (x == 1)
DoSomething(); //only this will be run, even if `DoSomething` changes `x` to 2
else if (x == 2)
DoSomethingElse();
While when you don't use it each of them may be run (depending on each of the conditions), i.e. each of them is estimated one by one:
// approach two
int x = 1;
if (x == 1)
DoSomething();//this is run, as `x` == 1
if (x == 2)
DoSomethingElse();//if `DoSomething` changes `x` to 2, this is run as well
So, IL may differ.