相关疑难解决方法(0)

为什么Func <T,bool>而不是Predicate <T>?

这只是一个好奇的问题,我想知道是否有人有一个很好的答案:

在.NET Framework类库中,我们有两个方法:

public static IQueryable<TSource> Where<TSource>(
    this IQueryable<TSource> source,
    Expression<Func<TSource, bool>> predicate
)

public static IEnumerable<TSource> Where<TSource>(
    this IEnumerable<TSource> source,
    Func<TSource, bool> predicate
)
Run Code Online (Sandbox Code Playgroud)

他们为什么用Func<TSource, bool>而不是Predicate<TSource>?好像Predicate<TSource>只由List<T>Array<T>,而Func<TSource, bool>所使用的几乎所有QueryableEnumerable方法和扩展方法...什么与怎么了?

.net c# predicate func

207
推荐指数
4
解决办法
5万
查看次数

标签 统计

.net ×1

c# ×1

func ×1

predicate ×1