搜索:
List<Product> product= new List<Product>();
product.Add(new Product(10, "name1"));
product.Add(new Product(500, "name2"));
product.Add(new Product(72, "name5"));
product.Add(new Product(9, "name4"));
List<Product> cheapest= product.FindAll(delegate(Product p) { return p.price < 25 || p.name.Contains("5"); });
product.Add(new Product(10, "name1"));
product.Add(new Product(500, "name2"));
product.Add(new Product(72, "name5"));
product.Add(new Product(9, "name4"));
List<Product> cheapest= product.FindAll(delegate(Product p) { return p.price < 25 || p.name.Contains("5"); });
排序:
product.Sort(delegate(Product p1, Product p2) { return p1.price.CompareTo(p2.price); });