Generic Delegate : Generic delegate « delegate « C# / CSharp Tutorial






using System;
using System.Collections.Generic;

delegate void FunctionToCall<T>(T value);                  

class MainClass
{
   static public void PrintString(string s)            
   {
      Console.WriteLine(s);
   }
   static public void PrintUpperString(string s)       
   {
      Console.WriteLine("{0}", s.ToUpper());
   }

   static void Main()
   {
      FunctionToCall<string> functionDelegate = PrintString;  
      functionDelegate += PrintUpperString;               
      functionDelegate("Hi There.");                              
   }
}
Hi There.
HI THERE.








9.9.Generic delegate
9.9.1.Generic Delegate
9.9.2.delegate constaints
9.9.3.Generic Delegate list
9.9.4.Create generic delegate from reflection
9.9.5.Return Type Inference With Multiple Returns