Linq中Lanbda表达式做参数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Lanbda表达式做参数
{
class Program
{
static void Main(string[] args)
{
int[] Array = new int[] { 3, 2, 4, 56, 6, 14, 53 };
Func<int, bool> mtDelB = delegate(int x) { return x % 2 == 1; };//匿名方法
var countOddA = Array.Count(x => x % 2 == 1);//Lambda表达式
var countOddB = Array.Count(mtDelB);
Console.WriteLine("A:The Count of odd numbers:{0}", countOddA);
Console.WriteLine("B:The Count of odd numbers:{0}", countOddB);
Console.ReadKey();
}
}
}