.net - Does anyone still use [goto] in C# and if so why? -


i wondering whether still uses "goto" keyword syntax in c# , possible reasons there doing so.

i tend view statements cause reader jump around code bad practice wondered whether there credible scenarios using such syntax?

goto keyword definition

there (rare) cases goto can improve readability. in fact, documentation linked lists 2 examples:

a common use of goto transfer control specific switch-case label or default label in switch statement.

the goto statement useful out of nested loops.

here's example latter one:

for (...) {     (...) {         ...         if (something)             goto end_of_loop;     } }  end_of_loop: 

of course, there other ways around problem well, such refactoring code function, using dummy block around it, etc. (see this question details). side note, java language designers decided ban goto , introduce labeled break statement instead.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -