Nesting Try Catch Exception In C#

2012-05-11


In some cases you can use nesting Try…Catch exception handling:

For example: A division-by-zero error

try
{
    try
    {
        Z = X / Y;
    }
    catch (DivideByZeroException ex)
    {
        Z = 0;
    }
  
    //... (other code)
}
catch (Exception ex)
{
    //exception processing
}