Catch Block With Exception Object : Try Catch « Language Basics « C# / C Sharp






Catch Block With Exception Object


using System;
using System.Collections;

class Class1 {
   static void Main(string[] args) {
    long lngResult;
    long lngValue = 0;

    try {
      lngResult = 8 / lngValue;
    }
    catch (Exception objE) {
      Console.WriteLine(objE.ToString());
    }
   }
}

           
       








Related examples in the same category

1.try and catch exception
2.Catch without Exception type
3.try catch with finally