title: Existing LINQ extension method similar to Parallel.For?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/200574/linq-equivalent-of-foreach-for-ienumerablet">LINQ equivalent of foreach for IEnumerable&lt;T&gt;</a>  </p>
  </blockquote>
  
  
  
  <p>The linq extension methods for ienumerable are very handy ... but not that useful if all you want to do is apply some computation to each item in the enumeration without returning anything.  So I was wondering if perhaps I was just missing the right method, or if it truly doesn't exist as I'd rather use a built-in version if it's available ... but I haven't found one :-)</p>
  
  <p>I could have sworn there was a .ForEach method somewhere, but I have yet to find it.  In the meantime, I did write my own version in case it's useful for anyone else:</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  
  public delegate void Function&lt;T&gt;(T item);
  public delegate void Function(object item);
  
  public static class EnumerableExtensions
  {
      public static void For(this IEnumerable enumerable, Function func)
      {
          foreach (object item in enumerable)
          {
              func(item);
          }
      }
  
      public static void For&lt;T&gt;(this IEnumerable&lt;T&gt; enumerable, Function&lt;T&gt; func)
      {
          foreach (T item in enumerable)
          {
              func(item);
          }
      }
  }
  </code></pre>
  
  <p>usage is:</p>
  
  <p><code>myEnumerable.For&lt;MyClass&gt;(delegate(MyClass item) { item.Count++; });</code></p>