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 can you ensure a permanent cookie?
How to find last error which occurred in Asp.net ?
Explain the Session state management options available with ASP.NET?
Define satellite assemblies.
What is applicatio domain?
What is a multilingual website?
What are the benefits of view state?
What are the event handlers that we can have in global.asax file?
Hi All, Im an MCA holder with 3+ years of experience in asp.net. Now i want to move to some good government job. I have no idea about different categories of exams held & which one can be applicable for my education background. I have done B.A with MCA. Please help me out with your valuable suggestions. I would be very grateful. Thanks Anuj
What is Web API?
What are the Types of session management in ASP.NET
How to display validation messages in one control?
What is query string in asp.net?
What is the concepts of globalization and localization in .net?
What are the layouts of ASP.NET Pages?