Use the 'catch all' catch statement. : Try Catch : Language Basics C# Examples


C# Examples » Language Basics » Try Catch »

 

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.");  
            }  
        }  
    }  
}
    
   
  
   



Output

Some exception occurred.
Some exception occurred.
Some exception occurred.
Some exception occurred.
Some exception occurred.
Some exception occurred.
Some exception occurred.
Some exception occurred.
Some exception occurred.
Some exception occurred.


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Language Basics
» Try Catch