首页 > 其他分享 >List扩展WhereIF

List扩展WhereIF

时间:2022-09-01 17:55:51浏览次数:62  
标签:predicate IEnumerable return WhereIF List 扩展 source where

 1 /// <summary>
 2 /// WhereIF扩展
 3 /// </summary>
 4 /// <typeparam name="TSource"></typeparam>
 5 /// <param name="source"></param>
 6 /// <param name="where"></param>
 7 /// <param name="predicate"></param>
 8 /// <returns></returns>
 9 public static IEnumerable<TSource> WhereIF<TSource>(this IEnumerable<TSource> source,bool where , Func<TSource, bool> predicate)
10 {
11 if (where)
12 return source.Where(predicate);
13 
14 return source;
15 }

 

标签:predicate,IEnumerable,return,WhereIF,List,扩展,source,where
From: https://www.cnblogs.com/g-w-j/p/16647378.html

相关文章