mirror of
https://github.com/rudollee/LearningMVC.git
synced 2026-08-12 00:42:57 +00:00
Delegate
This commit is contained in:
@@ -16,5 +16,27 @@ namespace LanguageFeatures.Models
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public static IEnumerable<Product> FilterByCategory(this IEnumerable<Product> productEnum, string categoryParam)
|
||||
{
|
||||
foreach (Product prod in productEnum)
|
||||
{
|
||||
if (prod.Category == categoryParam)
|
||||
{
|
||||
yield return prod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<Product> Filter(this IEnumerable<Product> productEnum, Func<Product, bool> selectorParm)
|
||||
{
|
||||
foreach (Product prod in productEnum)
|
||||
{
|
||||
if (selectorParm(prod))
|
||||
{
|
||||
yield return prod;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user