C# Extension Method To Add ForEach To Any IEnumerable


/ Published in: C#
Save to your folder(s)

This will allow you to use the LINQ ForEach method on any IEnumerable.


Copy this code and paste it in your HTML
  1. public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
  2. {
  3. foreach (T item in source)
  4. action(item);
  5. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.