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
What is the compiled object?
Explain the use of view state?
How can you handle errors in Web API?
What is the difference between cookie and session?
What r the asp.net list controls and diff. Between them?
Why do we need a web application session?
Explain about ASP.NET?
What are the advantages of asp.net?
Is session server side or client side?
We Only Know The Total Number Of Feet In The Farmyard. Write A Program that will compute the total number of rabbits and chickens in the farmyard. Assume number of feet in the farmyard are 40. how many rabbits and chickens are?
8. Why do you want to work here?
Explain how is a property designated as read-only?
How is my content secured from unauthorized access?
What are the authentication types in asp.net?
What is latest version of asp.net mvc? : Asp.Net MVC