the goto statement

M

Martin

Hi,

I would like to ask peoples opinion of the "goto" statement in C#.
I have always been taught NOT to use this statement in OO code (first OO
language I learned was C++ about 8 years ago) as it creates "saghettii
code"

I would have throught that using a function to "jump" to other code is far
better than a "goto" statement.

is this the general opinion of people or have a missed a good use of the
goto statement.

any comments appreciated.

cheers

martin.
 
B

Brad

Though I currently use vb it's probably been 20 years since I last used a
goto...having long ago been preached to about the evils of goto. Not only
does it make code more difficult to follow the more you use it but also its
need, to jump to a specific memory location for code, is somewhat dated (but
that's just my opinion).
 
S

Steve C. Orr [MVP, MCSD]

Never use Goto.
There is always a better way to approach the problem, such as function
calls, nesting code blocks, etc.
 
P

Peter Morris [Droopy eyes software]

GOTO was originally invented to jump over code.

10 if age < 18 then goto 40
20 ...
30 ...
40 (some more code here)

Once code segments were invented it made GOTO obsolete. I have no idea
why people still use GOTO in their code, and absolutely no idea why
people add GOTO to their languages.

--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top