- Home /
there is something i dont get (C# )
what dose Goto mean in C#?
Answer by Mike 3 · Apr 30, 2011 at 06:47 PM
The same as in most other languages - that you'll generally get a slap for using it :P
"The goto statement transfers the program control directly to a labeled statement"
http://msdn.microsoft.com/en-us/library/13940fs2(VS.71).aspx
Answer by hellcats · May 05, 2011 at 04:30 PM
The reason we're giving you such a hard time about goto is that it has a long history in Computer Science as a bad programming method. You do need transfer of control capability of course, but goto lets you transfer control to anywhere in your program, which can be very confusing when trying to figure out a bug or trying to understand someone else's code.
You can get by in almost all situations with "structured" control statments: while, if-then-else, for, switch, break, continue, return, yield, throw
These are structured because they sort of turn your program into an "outline" where statements control only more deeply nested blocks of code that appear immediately after it inside {...}. There are very few places where goto is actually needed (some would say there are no places). If you think you really need goto, then go ahead and use it, but most likely you could reorganize your code to make it understandable and modular by avoiding goto.
Answer by Dan 24 · May 01, 2011 at 01:33 AM
"In 1978, Berkeley scientists did a study on the effects of GoTo on rats. Twenty rats in a control group were fed a normal diet, while twenty other rats were forced to program in Apple BASIC. Their health was to be monitored for a month, but after two weeks all of the rats in the programming group had melted into a dense goo that tasted a little like quiche. " GoTo considered harmful
Answer by hellcats · May 01, 2011 at 03:50 AM
Goto is short for "Gotoga" (or go-Toga) which is a sideways reference to the 1978 cult classic "Animal House" starring John Belushi. Use of "goto" in programming languages (such as C#) means that you are thumbing your nose at established and accepted programming design principles and just doing your own "thing". Language designers of course are all aging hippie types themselves, and left "goto" in the language as a sort of homage to the anti-establishment sentiment. By using goto in your own programs you are making a stand against the "man" and keeping hippie culture alive in our modern connected world without raising the ire of your bosses or marketing types who will never know what it means.
Your answer
Follow this Question
Related Questions
IEnumerator problems in C# 2 Answers
Is Input.GetAxis meant to return to 0 on key up? 1 Answer
how can i fix this up so i can teleport? 1 Answer
Question regarding this line of code 1 Answer
how to convert int to string in C#? 2 Answers