A number of people have asked me why there is no Microsoft-provided "ForEach" sequence operator extension method. The List class has such a method already of course, but there's no reason why such a method could not be created as an extension method for all sequences. It's practically a one-liner:
public static void ForEach<T>(this IEnumerable<T> sequence, Action<T> action)
{ // argument null checking omitted
foreach(...Full Article.
No comments:
Post a Comment
Post your comments here: