The condemned “goto x;” jump statement – level 200

I’ve used all of the C# Jump statements.  You probably use break, continue, and return on a daily basis.  And in your switch statements, you probably use default.  But do you use the goto statement?  If you are like me, you’ve been conditioned since QBasic to avoid the infamous goto statement.  It creates spaghetti code, right?  Well, if you use it irresponsibly, it does, but what about nested if statements?  How do you jump out of 2 nested if statements?  break and continue don’t work.  My solution:  Use the goto statement.

<snippet>
if(condition 1)
{
statement;
statement;
if(condition 2)
{
statement;
goto endIf;
}
}
statement-that-should not happen if condition 2 is not met;
endIf:; //label to jump to and empty statement included.
</snippet>

You can probably think of several ways to refactor the above in order to avoid the goto statement, but in this case, the goto statement was the best decision, and this is a very valid use of the statement, and it does not create spaghetti code.