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 to deploy/publish webservices?How many ways?Plz explain me
What are the main differences between asp and asp.net?
Which namespace is used by ado.net?
Why we use dbms for projects? Why don’t we save any application data in separate files instead of dbms?
To get the values in two different controls to match which control you use it?
Explain difference betn dataset and recordset?
when a request is made in Life cycle of ASP.NET page .
What is session authentication?
How to add DateTime Control in normal DataGrid Server Control?
What are session objects?
What are custom user controls in asp.net?
Which control has default post back is enabled(true)?
What is rending process in ASP.NET?
What is the difference between a multi-layer and multi-tier applications?
Difference between overriding and overloading?