Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




QuestPond’s Interview Questions & Answers on .NET

Distinguish between catch with parameter and catch without parameter?

First let’s try to understand this question: - 

catch(Exception e)
{
…
}  

vs

Catch
{
…
}

For this interview question many people answer, “Second one will cause compile error”. But both the codes will work properly. Actually from .NET 2.0 there is no difference. But in the initial versions of .NET i.e. prior 2.0 some of the exceptions thrown by some COM components did not translate to “Exception” compatible object.

From .NET 2.0 both code will execute properly and there is no difference between them internally. Both catches will handle all kind of exceptions.

After 2.0 a catch which does have any code written in it gives a warning as shown below. So many developers mark this as a difference.

catch

But you can always overcome this issue by not putting a variable as shown in the below code: -

catch (Exception)
{

}

See the following on exception error handling: -

Click and see here for more learning on .NET


Helpful Website Url
http://www.questpond.com/
Share this article   |    Print    |    Article read by 4453 times
Author:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers
Related Articles:
Related Interview Questions: