|
Another interview question which was expecting a true / false answer and I wasn't too sure.
Duplicate http://stackoverflow.com/questions/582095/in-net-what-if-something-fails-in-the-catch-block-will-finally-always-get-call http://stackoverflow.com/questions...
Started by Gais on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
Finally will happen everytime for that try catch block
Finally block is guaranteed....
Generally the finally block is always executed regardless of exceptions (see other answers for more details).
Yes, finally is always executed.
|
|
I understand how try-catch works and how try-finally works, but I find myself using those (usually) in two completely different scenarios:
try-finally (or using in C# and VB) is mostly used around some medium-sized code block that uses some resource that...
Started by Heinzi on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
In order to be 100....
So to make it even more are expensive.
Of catch and finally together is to obtain and use resources in a try block, deal with exceptional circumstances in a catch block, and release the resources in the finally block.
|
|
Consider the following Cocoa/Obj-C code snippets:
MyClass *obj; @try { [obj doSomething]; } @catch (NSException * e) { NSLog(@"Exception occurred: %@", [e description]); } @finally { [obj cleanUp]; }
and
MyClass *obj; @try { [obj doSomething]; } @catch...
Started by Nick Forge on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
@finally is used to clean up when you either don’t catch the exception, or rethrow it, in either case leaving final exception response you don’t need to use @finally , which....
In that case, where you’re squashing the exception, none.
|
Ask your Facebook Friends
|
Hi,
In a try/catch/finally block like:
try { } catch() { // code fails here } finally { }
So if there is an exception in the catch block, will finally always get called?
What if there is no finally, will the code after the catch block get run?
Started by Blankman on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
If there's no finally block, the exception from the catch block will just be thrown up will cause the finally block not....
Assuming the process doesn't terminate abruptly (or hang, of course), the finally block will always be executed.
|
|
Hi all
try { // Do stuff } catch (Exception e) { throw; } finally { // Clean up }
In the above block when is the finally block called? Before the throwing of e or is finally called and then catch?
Started by Tom Andrews on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Why not try it:
outer try inner try inner catch inner finally outer catch outer finally....
; } } finally { // Clean up }
As a side note, if you really mean throw e; (that is, throw the same exception trace instead of creating a new one.
|
|
What happens if both catch and finally blocks throw exception?
Started by Arthur on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
When the finally block....
If the finally block throws an exception, the block will exit with an exception.
When catch throws an exception, finally block will be run and then exit with an exception.
The last exception thrown is thrown.
|
|
Quiz question: What is the output of running the following program:
Sub Main() Try CallToMethodThatThrowsException() Catch ex As ArgumentException Console.WriteLine("Argument exception caught") Finally Console.WriteLine("Outer finally block") End Try ...
Started by Ando on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
I'd assume:
inner finally block
argument exception caught
outer finally block
Argument exception caught
Inner finally block
Outer finally block
"Inner finally block"
"Argument exception caught"
"Outer finally....
|
|
Hi What is the best way to do nested try & finally statements in delphi?
var cds1 : TClientDataSet; cds2 : TClientDataSet; cds3 : TClientDataSet; cds4 : TClientDataSet; begin cds1 := TClientDataSet.Create(application ); try cds2 := TClientDataSet.Create...
Started by Charles Faiga on
, 7 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
If I find....
TClientDataSet.Create(nil); /// DO WHAT NEEDS TO BE DONE finally freeandnil(cds4); freeandnil(cds3 will result in dropping to the finally and performing all of the cleanup in the example you provided/finally scenario.
|
|
In a smackdown between the East Coast Worsters and the Pacific Pinoys who will have the glory for 10 whole minutes before we forget this season, this show, the contestants and these judges ever happened. Two groups battle for power voting bragging rights...
Started by Snidget on
, 53 posts
by 6 people.
Answer Snippets (Read the full thread at realitytvworld):
They get to come to the finally ON 05-23-12 AT 09:22 PM (EST) Darn, I was hoping she....
About their mentors.
For the finalists, with all the videos PP wasn't in .
Night! AI 11 Finally didn't give that away? I have a guest unitard you can use.
|
|
In a smackdown between the East Coast Worsters and the Pacific Pinoys who will have the glory for 10 whole minutes before we forget this season, this show, the contestants and these judges ever happened. Two groups battle for power voting bragging rights...
Started by Snidget on
, 54 posts
by 7 people.
Answer Snippets (Read the full thread at realitytvworld):
LAST....
From Driveshaft? literally.
Apparently in a large.
And the mentors are getting Ford Escapes Where Have You Been .
You? It was scream in a unitard night! AI 11 Finally didn't give that away? I have a guest unitard you to the finally.
|