Explicit or implicit execution control statement use
- by Andrei Rinea
I sometimes use
if (this._currentToolForeColor.HasValue)
return this._currentToolForeColor.Value;
else
throw new InvalidOperationException();
other times I use
if (this._currentToolForeColor.HasValue)
return this._currentToolForeColor.Value;
throw new InvalidOperationException();
The two are equivalent, I know, but I am not sure which is the best and why.
This goes even further as you can use other execution-control statements such as brake or continue :
while(something)
{
if(condition)
{
DoThis();
continue;
}
else
break;
}
versus
while(something)
{
if(condition)
{
DoThis();
continue;
}
break;
}
EDIT 1 : Yes the loop example(s) suck because they are synthetic (i.e.: made up for this question) unlike the first which is practical.