Use delegate as the function parameter : delegate parameter « delegate « C# / CSharp Tutorial






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);

   }

}
3








9.6.delegate parameter
9.6.1.Use delegate as the function parameter
9.6.2.Using a delegate to choose the right function to call.