Return delegate from a method : Return delegate « delegate « C# / CSharp Tutorial






using System;

public delegate void MyDeleage();

public class MainClass
{
    public static MyDeleage[] CreateDelegates() {
        MyDeleage[] delegates = new MyDeleage[3];
        
        for( int i = 0; i < 3; ++i ) {
            delegates[i] = delegate {
                Console.WriteLine( "Hi" ); 
            };
        }
        return delegates;
    }

    static void Main() {
        MyDeleage[] delegates = CreateDelegates();
        for( int i = 0; i < 3; ++i ) {
            delegates[i]();
        }
    }
}
Hi
Hi
Hi








9.7.Return delegate
9.7.1.Return delegate from a method