Interviews Questions and Answers



Why is catch(Exception) almost always a bad idea?

Posted by: Teena
On 23 Sep 2011 | Views: 1922 | Categories: C#
Interview Answers(2)

 On 01 Oct 2011 03:39:28 AM
Catch(Exception) is used when you are not sure that which exception will be thrown by the code.

This syntax will handle all system define exception.

Disadvantages of using this syntax is slowdowns the execution speed as CLR have to check each possible exception.
 On 01 Oct 2011 03:44:18 AM
catch(Exception) is a bad idea, because, in a code block we know what we have written and each code line has its own exception returns, so it should be of those types. Instead of catch(Exception) we can write multiple catch blocks with their exception types.

Post your Answers


Other lins

.Net Techies
Other lins