System.Exception is the base exception class. All exceptions in .NET are derived from System.Exception. : Exception in Method : Language Basics C# Examples


C# Examples » Language Basics » Exception in Method »

 

System.Exception is the base exception class. All exceptions in .NET are derived from System.Exception.









    
using  System;

public  class  Starter  {
        public  static  void  Main()  {
                try  {
                        int  var1  =  5,  var2  =  0;
                        var1  /=  var2;        //  exception  occurs
                }  catch  (Exception  except)  {
                        if  (except  is  SystemException)  {
                                Console.WriteLine("Exception  thrown  by  runtime");
                        }  else  {
                                Console.WriteLine("Exception  thrown  by  application");
                        }
                }
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Language Basics
» Exception in Method