Why do we need a finally block in try catch block while
handling exceptions

Answers were Sorted based on User's Feedback



Why do we need a finally block in try catch block while handling exceptions..

Answer / vijay kumar inumella

finally block will be executed irrespective of whether
the exception occured or not.
finally block is generally used to close the database
connections and to dispose the session objects etc.

Is This Answer Correct ?    12 Yes 1 No

Why do we need a finally block in try catch block while handling exceptions..

Answer / linto

For releasing unmanaged related objects from Garbage
collector.While,exception happen,the process flow may be
change.At that situation unmanaged objects like database
connection etc should be close.For that purpose we are
using finally block in try catch block.But,Idisposable is
better in the case of efficiency.

Is This Answer Correct ?    1 Yes 0 No

Why do we need a finally block in try catch block while handling exceptions..

Answer / santosh

The code which should execute at any cost even when an exception occurs that code should be written in finally block
ex-closing a form when exception occurs.

Is This Answer Correct ?    2 Yes 2 No

Why do we need a finally block in try catch block while handling exceptions..

Answer / amit

when we need to forcefully executed the code even any
exception will occurs.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is an abstract class c#?

0 Answers  


Explain why do I get an error (cs1006) when trying to declare a method without specifying a return type?

0 Answers  


Why References are stored on heap and variables on stack?

0 Answers   MCN Solutions,


Where do you add an event handler ?

1 Answers  


How long can a string be c#?

0 Answers  


if a method is marked as protected internal who can access it?

0 Answers   Siebel Systems,


How can you sort strings in array that are passed to method as arguments?

0 Answers  


Is there hashmap in c#?

0 Answers  


How many types of inheritance are there in c#?

0 Answers  


Why is ienumerable used?

0 Answers  


What is an assembly in dotnet?

0 Answers  


What Is The Difference Between ViewState and SessionState?

1 Answers   Fiserv,


Categories