人非木

大丈夫处世,不能立功建业,几与草木同腐乎?

linq lamada

   static void Main(string[] args)
        {
            List<Customer> cust = new List<Customer>() { 
                    new Customer{first="11",last="a1",ID="1",City="chian"},
                    new Customer{first="22",last="a2",ID="2",City="guangzhou"},
                    new Customer{first="33",last="a3",ID="3",City="beijing"},
                    new Customer{first="44",last="a4",ID="4",City="shanghai"}
            };
            //linq写法
            //IEnumerable<Customer> cus = from cu in cust where cu.City == "beijing" select cu;
            //lamada写法
            IEnumerable<Customer> cus = cust.Where(p => p.City == "beijing").Select(p => p);
            foreach (Customer item in cus)
            {
                Console.WriteLine(item.first + "," + item.last);
            }
            Console.ReadKey();
        }
    }
    class Customer
    {
        public string first { get; set; }
        public string last { get; set; }
        public string ID { get; set; }
        public string City { get; set; }
    }

 

posted on 2013-08-20 15:29  人非木  阅读(370)  评论(0编辑  收藏  举报

导航