Associating the delegate with an anonymous method. : delegate anonymous « Language Basics « C# / C Sharp
- C# / C Sharp
- Language Basics
- delegate anonymous
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);
}
}
Related examples in the same category