Exception Handling:Trying and Catching

image_pdfimage_print

   


using System;
public class TryingCatching
{
    static int Zero = 0;
    public static void Main()
    {
        // watch for exceptions here
        try
        {
            int j = 22 / Zero;
        }
        // exceptions that occur in try are transferred here
        catch (Exception e)
        {
            Console.WriteLine("Exception " + e.Message);
        }
        Console.WriteLine("After catch");
    }
}