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可以在对象列表中查寻符合条件的对象集合或者需要的有关对象列表的信息

相关文章:

  • 2021-12-04
  • 2022-12-23
  • 2021-11-11
  • 2021-07-02
  • 2021-09-29
  • 2021-04-21
  • 2021-11-14
  • 2021-10-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2022-03-02
  • 2022-01-09
  • 2022-12-23
相关资源
相似解决方案