牛骨文教育服务平台(让学习变的简单)
博文笔记

Linq中ForEach实现

创建时间:2014-04-22 投稿人: 浏览次数:4291
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{
  if (source == null)
    throw new ArgumentNullException("source");
  if (action == null)
    throw new ArgumentNullException("action");

  foreach (var item in source)
    action(item);
}

声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。