• How to Use Lambda Expressions in a Query


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

  • 相关阅读:
    数组
    对象
    js继承
    js原型原型链
    es6(初级)
    canvas背景
    Angular.js进阶
    Angular.js-2入门
    angular.js-1初识
    js之广告
  • 原文地址:https://www.cnblogs.com/xh831213/p/1278413.html
Copyright © 2020-2023  润新知