If exception occurs in Catch block itself then how to handle it in C#?
asp.net, c#
Solution
You can put a try catch inside the catch block, or you can simply throw the exception again. Its better to have finally block with your try catch so that even if an exception occurs in the catch block, finally block code gets executed.
try
{
}
catch(Excepetion ex)
{
try
{
}
catch
{
}
//or simply throw;
}
finally
{
// some other mandatory task
}
Finally block may not get executed in certain exceptions. You may see Constrained Execution Regions for more reliable mechanism.
Problem
//I have written code in Catch Block ``` try { } catch(Excepetion ex) { // I have written code here If Exception Occurs then how to handle it. } ```