Use delegate as the function parameter : Delegate parameter : Delegate C# Examples


C# Examples » Delegate » Delegate parameter »

 

Use delegate as the function parameter









    
using  System;
using  System.Collections.Generic;
using  System.Reflection;
using  System.Runtime.InteropServices;

delegate  void  FooBar();

public  class  MainClass
{
        static  void  Invoke3Times(FooBar  d)
        {
                d();  d();  d();
        }

      public  static  void  Main(){
                int  i  =  0;
                Invoke3Times(delegate  {  i++;  });
                Console.WriteLine(i);

      }

}
    
   
  
   



Output

3


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Delegate
» Delegate parameter