Posted By

hoffstein on 12/17/08


Tagged

csharp


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

hoffstein
umang_nine
paelgr
erlhal
danfinrud55
thedark


C# Extension Method To Add ForEach To Any IEnumerable


 / Published in: C#
 

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

  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  

You need to login to post a comment.