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
Define xmlreader class.
Explain the difference between Repeater and Data list control in ASP.NET?
What is the difference between mvc (model-view-controller) and mvp (model-view-presenter)? : asp.net mvc
What is the concept of postback in asp.net?
Explain the difference between webfarm and webgardens in .net?
What is the use of worker process in asp.net?
What is the main function of url routing system in asp.net mvc? : asp.net mvc
Which asp.net objects encapsulate the state of the client and the browser?
What are strong names?
What are the page life cycle events?
Why viewstate is used in asp.net?
Where you store Connection string in "Web.Config" file in ASP.NET?
How many types of session state management options available in asp.net?
How do you handle server controls?
What is the life cycle of web page?