ForEach, a simple but very useful extension method

August 21, 2008 01:24 by admin

Glenn Block has an implementation of ForEach for IEnumerable:

  1: public static class IEnumerableUtils {
  2:   public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action) {
  3:     foreach(T item in collection) {
  4:     action(item);
  5:   }
  6: }

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

November 19. 2008 20:21