• Linq 演变的过程(delegate => Lamb => Linq)


    演变的过程(delegate => Lamb => Linq)
    1.
    Func
    <string,bool> filter = delegate(string s){
                                
    return s.Length == 5;}
    ;
    Func
    <string,string> extract = delegate(string s){
                                
    return s;}

    Func
    <string,string> project = delegate(string s){
                                
    return s.ToUpper();}


    IEnumerable
    <string> query = names
                                .where(filter)
                                .orderby(extract)
                                .select(project);
    2.
    IEnumerable
    <string> query = names
                                .where(s 
    => s.Length ==5)
                                .orderby(s 
    => s)
                                .select(s 
    => s.ToUpper())

    3.
    IEnumerable
    <string> query = from s in names
                                where s.Length 
    ==5
                                orderby s
                                select s.ToUpper();
    了解了代码的演变,有助于对linq有一个初步认识.
  • 相关阅读:
    I'm Telling the Truth
    B-shaass and lights codeForces
    1
    不容易系列之(4)——考新郎 HDU
    犯人冲突
    不互质的和
    OI回忆录
    NOI2018退役记
    uoj221【NOI2016】循环之美
    uoj220【NOI2016】网格
  • 原文地址:https://www.cnblogs.com/RuiLei/p/784852.html
Copyright © 2020-2023  润新知