e.g. 5.20 Using a Lambda Expression to Replace a Delegate Definition

chap5
Jason Zhu 2021-07-12 13:32:22 +10:00
parent be286cffbd
commit c95b347b15
1 changed files with 1 additions and 5 deletions

View File

@ -21,11 +21,7 @@ namespace automatically_implemented_properties
} }
}; };
Func<Product, bool> categoryFilter = delegate(Product prod) Func<Product, bool> categoryFilter = prod => prod.Category == "Soccer";
{
return prod.Category == "Soccer";
};
IEnumerable<Product> filteredProducts = products.Filter(categoryFilter); IEnumerable<Product> filteredProducts = products.Filter(categoryFilter);
foreach (Product prod in filteredProducts) foreach (Product prod in filteredProducts)