zoukankan      html  css  js  c++  java
  • 7. 关键字

    let关键字

    • 不使用let关键字
    IList<Student> studentList = new List<Student>() {
        new Student() { StudentID = 1, StudentName = "John", Age = 18 } ,
        new Student() { StudentID = 2, StudentName = "Steve",  Age = 21 } ,
        new Student() { StudentID = 3, StudentName = "Bill",  Age = 18 } ,
        new Student() { StudentID = 4, StudentName = "Ram" , Age = 20 } ,
        new Student() { StudentID = 5, StudentName = "Ron" , Age = 21 }
    };
    //需要做2次的小写转化
    var lowercaseStudentNames = from s in studentList
                                where s.StudentName.ToLower().StartsWith("r")
                                select s.StudentName.ToLower();
    • 使用let关键字
    var lowercaseStudentNames = from s in studentList
                                let lowercaseStudentName = s.StudentName.ToLower()
                                    where lowercaseStudentName.StartsWith("r")
                                    select lowercaseStudentName;
    
    foreach (var name in lowercaseStudentNames)
        Console.WriteLine(name);
    

    into关键字

    var teenAgerStudents = from s in studentList
        where s.age > 12 && s.age < 20
        select s
            into teenStudents
            where teenStudents.StudentName.StartsWith("B")
            select teenStudents;
    
  • 相关阅读:
    快速排序
    冒泡排序算法
    设计模式之工厂方法模式
    调用存储过程修改
    取出字符串中的回车空格
    调用存储过程实例
    C++左值
    cocos2d-x 不规则形状按钮的点击判定
    C/C++
    字符函数库 cctype
  • 原文地址:https://www.cnblogs.com/maanshancss/p/13087151.html
Copyright © 2011-2022 走看看