The goto
Statement
In true C and C++ style, C# provides a goto
statement to perform unconditional control transfer to a point in the code marked by a label. The greatest computer scientists have debated the use of goto
for years:
• Edsger Dijkstra, a Dutch computer scientist, published his infamous paper “Go To Statement Considered Harmful” in 1968. At that time, structured programming (if, while, and so on) was gaining popularity, and most typical cases of goto got eliminated by it. And true, use of goto
all over the place quickly results in spaghetti code.
• Donald Knuth, known for his “The Art of Computer Programming” series, stated this viewpoint is too extreme and argued that in some cases use of the goto
statement still makes sense. He ...
Get C# 4.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.