为什么使用Func而不是Predicate

17 浏览
0 Comments

为什么使用Func而不是Predicate

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

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

public static IQueryable Where(
    this IQueryable source,
    Expression> predicate
)
public static IEnumerable Where(
    this IEnumerable source,
    Func predicate
)

为什么它们使用`Func`而不是`Predicate`?看起来`Predicate`只被`List`和`Array`使用,而`Func`几乎被所有的`Queryable`和`Enumerable`方法和扩展方法使用...这是怎么回事?

0