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


Please Help Members By Posting Answers For Below Questions

How to deploy/publish webservices?How many ways?Plz explain me

1833


What are the main differences between asp and asp.net?

516


Which namespace is used by ado.net?

558


Why we use dbms for projects? Why don’t we save any application data in separate files instead of dbms?

548


To get the values in two different controls to match which control you use it?

524






Explain difference betn dataset and recordset?

525


when a request is made in Life cycle of ASP.NET page .

526


What is session authentication?

526


How to add DateTime Control in normal DataGrid Server Control?

577


What are session objects?

508


What are custom user controls in asp.net?

508


Which control has default post back is enabled(true)?

601


What is rending process in ASP.NET?

611


What is the difference between a multi-layer and multi-tier applications?

566


Difference between overriding and overloading?

697