65.9K
CodeProject is changing. Read more.
Home

The goto-less goto!

starIconstarIconstarIconstarIconemptyStarIcon

4.00/5 (4 votes)

Feb 7, 2011

CPOL
viewsIcon

10557

Usually, gotos are used to clean up resources when exiting a function. I would recommend using the RAII[^] idiom. It also works works well in the presence of exceptions.For C# I would use IDisposable/using. If that's not possible, I'd use a finally clause to clean up.Everything else...

Usually, gotos are used to clean up resources when exiting a function. I would recommend using the RAII[^] idiom. It also works works well in the presence of exceptions. For C# I would use IDisposable/using. If that's not possible, I'd use a finally clause to clean up. Everything else will eventually end up being messy.