Can we throw exception from catch block ?
Answer Posted / 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 |
Post New Answer View All Answers
How asynchronous call can be implemented using delegates?
What is the concept of postback in asp.net?
What is the parent class of all the web server control?
What is inproc mode in session?
Will the asp.net validators run in server side or client side? How do you do client-side validation in .net?
How to Insert/Add in ASPXgridview
How do you declare static variable?
Distinguish between Server-side and Client-side code?
Which is an advantage of application service providers?
Any disadvantages in Dataset and in reflection ?
What is cached data phone?
what are configuration files?
How to find last error which occurred?
Explain the role of global.asax?
What does asax stand for?