e.g. 5.20 Using a Lambda Expression to Replace a Delegate Definition
parent
be286cffbd
commit
c95b347b15
|
@ -20,12 +20,8 @@ namespace automatically_implemented_properties
|
|||
new Product {Name = "Corner flag", Category = "Soccer", Price = 34.95M}
|
||||
}
|
||||
};
|
||||
|
||||
Func<Product, bool> categoryFilter = delegate(Product prod)
|
||||
{
|
||||
return prod.Category == "Soccer";
|
||||
};
|
||||
|
||||
Func<Product, bool> categoryFilter = prod => prod.Category == "Soccer";
|
||||
IEnumerable<Product> filteredProducts = products.Filter(categoryFilter);
|
||||
|
||||
foreach (Product prod in filteredProducts)
|
||||
|
|
Loading…
Reference in New Issue