public void SelectItems() { Product[] products = new Product[] { new Product(){Name="啤酒", Count = 100 , Price=2.5 }, new Product(){Name="冰峰", Count = 50 , Price=1.5 }, new Product(){Name="可乐", Count = 80 , Price=3.5 }, }; var selectedProduct = from p in products where (p.Count > 60 && p.Price > 2) select p; foreach (Product p in selectedProduct) { } }
public void AddProduct(Product product) { products.Add(product); }