C#3.5技术探讨(7) :Linq To Object with Lambda Expressions

/*--===------------------------------------------===---
Linq To Object with Lambda Expressions
            许明会    2007年12月3日 22:51:59
--===------------------------------------------===---
*/
using System;
using System.Linq;

namespace xumh
{
    
public class myClass
    {
    };

    
public class runMyApp
    {
        
static void Main()
        {
            var score 
= new []{12,243,54,65,67,8};
            Console.WriteLine(
"和为{0},平均值为{1}.",
                score.Sum(), score.Average());
            var my 
= score.Where(p => p>20);
            
//var my = from p in score where p>20 select p;
            foreach(var v in my)
                Console.WriteLine(
"{0}\t",v);
            Console.WriteLine(
"和为{0}.",my.Sum());
        }
    };
}
原文地址:https://www.cnblogs.com/flaaash/p/981632.html