Nesting Try Catch Exception In C#

Published on Friday, May 11, 2012

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
}