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 the difference between string and stringbuilder in c#?

0 Answers  


What is manifest ?

3 Answers   Digital GlobalSoft,


Why reflection is used in c#?

0 Answers  


Hoe can i connect the table into the c# application?

2 Answers  


What is attribute and reflection in c#?

0 Answers  






How can you prevent classes to be inherited?

10 Answers   Microsoft, Satyam,


What is difference between static and constant variable?

0 Answers  


What do you mean by saying a "class is a reference type"?

0 Answers  


What is the resgen.exe tool used for?

0 Answers  


what is the difference between interface and abstraction?

5 Answers   Choice Solutions, IBM,


What is the difference between string keyword and system.string class?

0 Answers  


What?s an interface class?

1 Answers  


Categories