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; }
}