Declare recursive function and in main in c#



In programming terms, a recursive function can be defined as a routine that calls itself directly or indirectly.

  1. class MainClass  
  2. {  
  3.     public static void Main()  
  4.     {  
  5.         try  
  6.         {  
  7.             RecursiveFunction();  
  8.         }  
  9.         catch(StackOverflowException)  
  10.         {  
  11.             Console.WriteLine("Out of stack space.");  
  12.         }  
  13.     }  
  14.      
  15.     public static void RecursiveFunction()  
  16.     {  
  17.         RecursiveFunction();  
  18.     }  
  19. }  
 

0 Comment's

Comment Form

Submit Comment