Can we throw exception from catch block ?
Answers were Sorted based on User's Feedback
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 |
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 |
Answer / vamshi krishna
Try
{
//Implemented code
}
catch(ex)
{
alert(ex.message)
}
Is This Answer Correct ? | 1 Yes | 4 No |
How many languages are supported by .NET at present time?
About SOAP ?
what is CTS?
can we remote debug applications with the remote debugger installed with vs.net 2002, with vs.net 2003?
What is tracing? Where is it used?
Explain asp.net page life cycle?
How we can force all the validation controls to run?
How can you change a Master page dynamically in which event of page life cycle?
version information of assembly consist of _________ values.
What is autopost?
What is the difference between Hash table and Array list?
what is loosely coupled solution? How it can be used?