e.g. 5.20 Using a Lambda Expression to Replace a Delegate Definition
parent
be286cffbd
commit
c95b347b15
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue