Exception Handling: The Exception Hierarchy 1
using System;
public class ExceptionHierarchy
{
static int Zero = 0;
public static void Main()
{
try
{
int j = 22 / Zero;
}
// catch a specific exception
catch (DivideByZeroException e)
{
Console.WriteLine("DivideByZero {0}", e);
}
// catch any remaining exceptions
catch (Exception e)
{
Console.WriteLine("Exception {0}", e);
}
}
}
Related examples in the same category