zoukankan      html  css  js  c++  java
  • C#3.0技术探讨(6) :Lambda表达式 Lambda Expressions

    /*--===------------------------------------------===---
    Lambda表达式 Lambda Expressions

                许明会    2007年12月3日 20:11:40
    --===------------------------------------------===---
    */
    using System;
    using System.Collections.Generic; //引入泛型
    using System.Linq;    //Lambda表达式查询必须引入Linq空间

    namespace xumh
    {
        
    public class student
        {
            
    public string firstname{get;set;}
            
    public string lastname{get;set;}
            
    public string corperation{get;set;}
        }

        
    public class runMyApp
        {
            
    static void Main()
            {
                List
    <student> stu = new List<student> {
                    
    new student{firstname="xu", lastname="minghui", corperation="jbird"},
                    
    new student{firstname="sun", lastname="weiping", corperation=""},
                    
    new student{firstname="xu", lastname="zihao", corperation="home"}
                };
                
    //p => p.firstname.StartsWith("xu") //这就是Lambda表达式
                var result = stu.Where(p => p.firstname.StartsWith("xu"));
                
    //var result = from p in stu where p.firstname.StartsWith("xu") select p;
                foreach(var v in result)
                    Console.WriteLine(
    "{0} {1},工作于{2}.",
                        v.firstname, v.lastname, v.corperation);
            }
        }
    }

  • 相关阅读:
    JQuery基础知识总结
    抽象方法与虚方法
    关于性能的几个术语
    T-SQL基础知识
    学习materialize
    VS2013 启用avalon 智能提示 Intelligence
    推荐一款开源的C#TCP通讯框架
    js/jquery 获取本地文件的文件路劲 获取input框中type=‘file’ 中的文件路径(转载)
    HTML5的 input:file上传类型控制(转载)
    tinymce4.x 上传本地图片 (转载)
  • 原文地址:https://www.cnblogs.com/flaaash/p/981502.html
Copyright © 2011-2022 走看看