Lambda表达式

    string[] names = { "agen", "balen", "coure", "apple" };
  string[] findNameA = Array.FindAll<string>(names, delegate(string v) { return v.StartsWith("a"); });
  string[] findNameB = Array.FindAll<string>(names, v => v.StartsWith("a"));
  上面中两个FindAll方法的反编译代码如下:
  string[] findNameA = Array.FindAll<string>(names, delegate (string v) { return v.StartsWith("a"); } );
  string[] findNameB = Array.FindAll<string>(names, delegate (string v) { return v.StartsWith("a"); } );
  从而可以知道“Lambda表达式”与“匿名方法”是可以划上等号的,只不过使用“Lambda表达式”输写代码看上去更直观漂亮,不是吗?


你可能感兴趣的:(Lambda表达式)