An exception is an error that occurs at runtime.
using System;
class MainClass{
public static void Main(){
int Zero = 0;
try {
int j = 22 / Zero;
} catch (DivideByZeroException e) // catch a specific exception
{
Console.WriteLine("DivideByZero {0}", e);
} catch (Exception e)// catch any remaining exceptions
{
Console.WriteLine("Exception {0}", e);
}
}
}
DivideByZero System.DivideByZeroException: Attempted to divide by zero.
at MainClass.Main()