Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0186 delegate with generic type

delegate can have generic type. using System; delegate void Printer<T>(T t); class Test { static void consolePrinterInt(int i) { Console.WriteLine(i); } static void consolePrinterFloat(float f) { Console.WriteLine(f); } static void Main() { Printer<int> p = consolePrinterInt; p(2); } }