How to loop through a collection that supports IEnumerable?
How to loop through a collection that supports IEnumerable?
You might also try using extensions if you like short code:
namespace MyCompany.Extensions
{
public static class LinqExtensions
{
public static void ForEach<TSource>(this IEnumerable<TSource> source, Action<TSource> actor) { foreach (var x in source) { actor(x); } }
}
}
This will generate some overhead, for the sake of having stuff inline.
collection.Where(item => item.IsReady).ForEach(item => item.Start());