Generic Delegate : Generic delegate : Delegate C# Examples


C# Examples » Delegate » Generic delegate »

 

Generic Delegate









    
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.");                                                            
      }
}
    
   
  
   



Output

Hi There.
HI THERE.


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Delegate
» Generic delegate