Mega Code Archive

 
Categories / C# / Language Basics
 

Associating the delegate with an anonymous method

delegate void Printer(string s); class TestClass {     static void Main()     {         Printer p = delegate(string j)         {             System.Console.WriteLine(j);         };         p("this is a test.");     }     static void DoWork(string k)     {         System.Console.WriteLine(k);     } }