C# 多参数线程以及匿名函数(轉)

  • 73
  • 0

C# 多参数线程以及匿名函数(轉)

 

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

————————————————
版权声明:本文为CSDN博主「小索」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/fenglifeng1987/article/details/19685129

C# 多参数线程以及匿名函数(轉)