Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] [OT] C# question -- try / catch / finally
- Date: Thu, 21 Nov 2013 20:00:22 -0500
- From: jep200404@example.com
- Subject: Re: [tlug] [OT] C# question -- try / catch / finally
- References: <528E3A9C.7080606@bonivet.net>
On Thu, 21 Nov 2013 16:53:48 +0000, Godwin Stewart <gstewart@example.com> wrote: > ... C# ... > try { > doSomething(); > doSomethingElse(); > areWeDoneAlready(); > } > catch (SomeKindOfException) { > kaboom(); > } > finally { > cleanup(); > } > Surely this is functionally equivalent: > > try { > doSomething(); > doSomethingElse(); > areWeDoneAlready(); > } > catch (SomeKindOfException) { > kaboom(); > } > cleanup(); Well maybe not. A web search for C# try finally led to a page by C#'s sponsor which seemed to indicate that the finally is executed even if a break, continue, goto, or return happens in the try section. This expands on what Benjamin Tayehanpour wrote. I don't know C# syntax, so the following has speculative syntax. while (true) { try { if (doSomething()) { break; } if (doSomethingElse()) { continue; } if (areWeDoneAlready()) { return; } if (toTheMoonAlice()) { goto TheMoon } } catch (SomeKindOfException) { kaboom(); } finally { cleanup(); # Will this happen even if break, continue, return, or goto happens? } TheMoon: ; }
- Follow-Ups:
- Re: [tlug] [OT] C# question -- try / catch / finally
- From: Godwin Stewart
- Re: [tlug] [OT] C# question -- try / catch / finally
- From: Benjamin Tayehanpour
- References:
- [tlug] [OT] C# question -- try / catch / finally
- From: Godwin Stewart
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] [OT] C# question -- try / catch / finally
- Next by Date: Re: [tlug] [OT] C# question -- try / catch / finally
- Previous by thread: Re: [tlug] [OT] C# question -- try / catch / finally
- Next by thread: Re: [tlug] [OT] C# question -- try / catch / finally
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links