try and catch exception : Try Catch « Language Basics « C# / C Sharp






try and catch exception

    using System;
    using System.Collections;

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

    try {
      lngResult = 8 / lngValue;
    }
    catch {
      Console.WriteLine("catch");
    }
    finally {
      Console.WriteLine("finally");
    }
   }
}


           
       








Related examples in the same category

1.Catch without Exception type
2.try catch with finally
3.Catch Block With Exception Object