Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'        Annotated program -- Keyboard shortcut: 't'    introductory-examples/control-structures/try-catch-demo.cs - Demonstrations of try catch.Lecture 2 - slide 14 : 43
Program 5

/* Right, Wrong */
using System;

class TryCatchDemo {
  public static void Main(){
    int i = 5, r = 0, j = 0;

    /*
    r = i / 0;  
    Console.WriteLine("r is {0}", r);   
    */

    try {       
      r = i / j;
      Console.WriteLine("r is {0}", r);
    } catch(DivideByZeroException e){
        Console.WriteLine("r could not be computed");
    }   
  }      
}