点滴积累,融会贯通

-----喜欢一切有兴趣的东西

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
    var categories =
    from student 
in students
    group student by student.Year into studentGroup
    select 
new { GradeLevel = studentGroup.Key, TotalScore = studentGroup.Sum(s => s.ExamScores.Sum()) };

    
// Execute the query.   
    foreach (var cat in categories)
    {
        Console.WriteLine(
"Key = {0} Sum = {1}", cat.GradeLevel, cat.TotalScore);
    }

 

 

string[] words = { "cherry""apple""blueberry" };
int shortestWord = words.Min((string w) => w.Length);

 

 

说明:使用Lambda可以在对象列表中查寻符合条件的对象集合或者需要的有关对象列表的信息

posted on 2008-08-28 10:43  小寒  阅读(392)  评论(0编辑  收藏  举报