Lambda 表达式应用
我们不会在查询语法中直接用到 Lambda 表达式,但会在方法调用中用到这些表达式,并且查询表达式可以包含方法调用。
class SimpleLambda
{
static void Main()
{
// Data source.
int[] scores = { 90, 71, 82, 93, 75, 82 };
// The call to Count forces iteration of the source
int highScoreCount = scores.Where(n => n > 80).Count();
// Outputs: 4 scores are greater than 80
Console.WriteLine("{0} scores are greater than 80", highScoreCount);
}
}