/* C # development history of delegation :. net 1.x delegate =>. net 2.x anonymous method =>. net 3.0/3.5 Lambda expression MS-help: // Ms. msdnqtr. v90.chs/dv_csref/html/6ce3f04d-0c71-4728-9127-634c7e9a8365.htm in C #1.0. Code Explicitly initialize the delegate to create the delegated instance. C #2.0 introduces the concept of anonymous methods, as a way to compile unnamed inline statement blocks that can be executed in a delegate call. C #3.0 introduces lambda expressions, which are similar to anonymous methods but more expressive and concise. These two functions are collectively referred to as "anonymous functions ". Typically, applications with. NET Framework Version 3.5 and later Program Lambda expressions should be used. The following example demonstrates the development of the delegate creation process from C #1.0 to C #3.0: */namespace microshaoft {using system; class test {// C #1.0 delegate void testdelegate (string S); static void M (string s) {console. writeline (s);} static void main (string [] ARGs) {// original delegate syntax required // initialization with a named method. testdelegate testdela = new testdelegate (m); // C #2.0: A delegate can be initialized with // Inline code, called an "anonymous method. "This // method takes a string as an input parameter. testdelegate testdelb = delegate (string S // parameter) // anonymous function {console. writeline (s) ;};// C #3.0. A delegate can be initialized with // a Lambda expression. the Lambda also takes a string // as an input parameter (X ). the type of X is inferred by the compiler. testdelegate testdelc = (x) // parameter => // anonymous function {console. writeline (x) ;}; // invoke the delegates. testdela ("hello. my name is m and I write lines. "); testdelb (" that's nothing. i'm anonymous and "); testdelc (" I'm a famous author. "); // keep Console window open in debug mode. console. writeline ("press any key to exit. "); console. readkey () ;}/ * output: Hello. my name is m and I write lines. that's nothing. i'm anonymous and I'm a famous author. press any key to exit. */}