static void Main(string[] args) { myGenericDelegate <string> del = new myGenericDelegate <string>(StrTarget); myGenericDelegate <int> del2 = new myGenericDelegate <int>(IntTarget); del("5"); del2(2); Console.ReadKey(); }
public void DelegateOutput() { myDelegate myAddFunction = WorkerClass.Add; int sum = myAddFunction(10, 30); Console.WriteLine($"By Using Delegate {sum}"); myGenericDelegate <int> myGenericDelegate = WorkerClass.Sum; Console.WriteLine($"By Using Geniric Delegate {myGenericDelegate(40)}"); }