Alex Rivera | Logout

Use a 'goto' in a switch?

Asked 2011-01-21T06:37:41.993
63

I've seen a suggested coding standard that reads Never use goto unless in a switch statement fall-through.

I don't follow. What exactly would this 'exception' case look like, that justifies a goto?

Edit
Report

1 Answer

4

It's the only way that C# allows a switch case 'fallthrough'. In C# (unlike C, C++ , or Java), a case block in a switch statement must end with a break or some other explicit jump statement.

answered 2011-01-21T06:41:32.280

Your Answer