LINQ's ForEach doesn't work on IEnumerable<T>
For some reason, LINQ’s ForEach extension method doesn’t work on IEnumerable<T>
; it only works on IList<T>
. Easy fix:
public static class EnumerableExtensions
{
public static void ForEach<T>(this IEnumerable<T> values, Action<T> action)
{
foreach (var value in values)
{
action(value);
}
}
}