Can we throw exception from catch block ?

Answers were Sorted based on User's Feedback



Can we throw exception from catch block ?..

Answer / nilesh

Yes. A throw statement can be used in the catch block to re-
throw the exception, which has been caught by the catch
statement. For example:

catch (InvalidCastException e)
{
throw (e); // Rethrowing exception e
}

Is This Answer Correct ?    4 Yes 0 No

Can we throw exception from catch block ?..

Answer / arjun

The exceptions, which we caught inside a catch block, can
re-throw to a higher context by using the keyword throw
inside the catch block. The following program shows how to
do this.

//C#: Exception Handling: Handling all exceptions
using System;
class MyClass
{
public void Method()
{
try
{
int x = 0;
int sum = 100/x;
}
catch(DivideByZeroException e)
{
throw;
}
}
}
class MyClient
{
public static void Main()
{
MyClass mc = new MyClass();
try
{
mc.Method();
}
catch(Exception e)
{
Console.WriteLine("Exception caught here" );
}
Console.WriteLine("LAST STATEMENT");
}
}

Is This Answer Correct ?    3 Yes 0 No

Can we throw exception from catch block ?..

Answer / jignesh panchal

yes

Is This Answer Correct ?    2 Yes 1 No

Can we throw exception from catch block ?..

Answer / vamshi krishna

Try
{
//Implemented code
}
catch(ex)
{
alert(ex.message)
}

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More ASP.NET Interview Questions

If iam developing an application that must accomodate multiple security levels though secure login and my asp.net web appplication is spanned across three web-servers (using round-robbin load balancing) what would be the best approach to maintain login-in state for the users?

0 Answers  


Why asp.net is used?

0 Answers  


What are the Types of authentications in IIS

0 Answers   Microsoft,


what are configuration files?

0 Answers  


What is asp.net web application?

0 Answers  






What would be salary for 6+ years of experience in ASP.NET in different metro city in india?

4 Answers  


Why do you use the app_code folder in asp.net?

0 Answers  


Explain the life cycle of an ASP .NET page.

2 Answers  


What is the Difference B/W Finalize() and Dispose() in .Net?

12 Answers   HCL, IBM,


What is deff. saop and disco?

1 Answers  


what is difference between java and .net

11 Answers   Base2 Infotech, Karur Vysya Bank KVB, TATA AIG, TCC,


What are the ways to sending the data in ASP.NET page?

0 Answers  


Categories