a generic delegate being initialized with a normal method : Generic delegate « Generics « C# / C Sharp






a generic delegate being initialized with a normal method

 

using System;

public delegate void DelegateClass<T>(T data);
public class Starter {
    public static void Main() {
        DelegateClass<string> del = MethodA;
        del("data");
    }

    public static void MethodA(string data) {
        Console.WriteLine("MethodA ({0})", data);
    }
}

 








Related examples in the same category

1.A simple generic delegateA simple generic delegate
2.Convert event to use generic delegateConvert event to use generic delegate
3.Generic Delegate and non-generic delegate
4.Generics and Delegates
5.Generic Anonymous Methods