Nitin Taneja
I can think of nothing less pleasurable than a life devoted to pleasure !!
Tuesday, March 20, 2012
LINQ equivalent of foreach for IEnumerable
There is no ForEach extension for IEnumerable as it is only for List. So you could do
This is not working -
IEnumerable
items = GetItems();
items.ForEach(i => i.DoStuff());
You can add tolist before doing foreach -
items.ToList().ForEach(i => i.DoStuff());
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)