匿名方法

  在 2.0 之前的 C# 版本中,声明委托的唯一方法是使用命名方法。C# 2.0 引入了匿名方法,而在 C# 3.0 及更高版本中,Lambda 表达式取代了匿名方法,作为编写内联代码的首选方式。
  要将代码块传递为委托参数,创建匿名方法则是唯一的方法。
  通过使用匿名方法,由于您不必创建单独的方法,因此减少了实例化委托所需的编码系统开销。
  示例:
  不使用匿名方法:
  static void Main(string[] args)
  {
   Thread thread = new Thread(new ThreadStart(Run));
   thread.Start();
  }

  static void Run()
  {
   // 要运行的代码 ...
  }

  2.0之后可以使用匿名方法:
  static void Main(string[] args)
  {
   Thread thread = new Thread(delegate()
   {
    // 要运行的代码
   });
   thread.Start();
  }

原文地址:https://www.cnblogs.com/yellowapplemylove/p/2021593.html