IEnumrable Foreach方法扩展
2012-09-11 12:41:38 来源:WEB开发网核心提示:public static IEnumerable<T> ForEach<T>(this IEnumerable<T> source, Action<T> action) where T : class,new() { foreach
public static IEnumerable<T> ForEach<T>(this IEnumerable<T> source, Action<T> action) where T : class,new()
{
foreach (var item in source)
{
action(item);
yield return item;
}
}
Tags:IEnumrable Foreach 方法
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接
