Mega Code Archive

 
Categories / C# Tutorial / Language Basics
 

Use the catch all catch statement

using System;    class MainClass {    public static void Main() {      int[] numer = { 4, 8};      int d = 0;          for(int i=0; i < 10; i++) {        try {          Console.WriteLine(numer[i] + " / " +                             numer[i] + " is " +                             numer[i]/d);        }        catch {          Console.WriteLine("Some exception occurred.");        }      }    }  } Some exception occurred. Some exception occurred.