List.ForEach method and collection interfaces
Posted
by tyndall
on Stack Overflow
See other posts from Stack Overflow
or by tyndall
Published on 2010-06-02T21:46:19Z
Indexed on
2010/06/02
21:54 UTC
Read the original article
Hit count: 146
In .NET 3.5 List<> gains a ForEach method. I notice this does not exist on IList<> or IEnumerable<> what was the thinking here? Is there another way to do this? Nice and simple short way to do this?
I ask because I was at a talk where the speaker said always use the more general interfaces. But why would I use IList<> as a return type if I want to be able to turn around and use ForEach? Then I would just end up casting it back to a List<>.
© Stack Overflow or respective owner