ForEach extension for IEnumerable - by Michael_Giagnocavo

Status : 

  External<br /><br />
		This item may be valid but belongs to an external system out of the direct control of this product team.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 279093 Comments
Status Closed Workarounds
Type Suggestion Repros 13
Opened 5/30/2007 11:45:09 AM
Access Restriction Public


Please add a ForEach extension method for IEnumerable. I know it doesn't fit into the idea of a query language, but implementations like LINQ for XML already have similar methods. For instance, System.Xml.Linq.Extensions.Remove<T> returns void and is essentially doing a foreach calling Remove (from the perspective of the user), isn't it? 

Also, Array has a static method, and List has an instance method of ForEach so why not IEnumerable?
Sign in to post a comment.
Posted by Thurein on 12/31/2009 at 11:55 PM
ForEach() method for IEnumerable would be very helpful.
Posted by Kirill Osenkov - MSFT on 1/31/2009 at 11:43 PM
I feel that we need to add this because of huge community demand.
Posted by FalconNL2007 on 8/15/2007 at 3:58 AM
Agreed. Having to use ToList or make an extension method every time is rather annoying. Making it a built-in method will save some typing.
Posted by Microsoft on 6/11/2007 at 10:00 AM

Thanks for your suggestion. We will consider such a feature for a future version of the Framework. Please also visit for updates and info on Base Class Libraries.

Inbar Gazit