0

I've been calling the following Linq method:

public static bool Any<TSource>(
    this IEnumerable<TSource> source,
    Func<TSource, bool> predicate
)

I'm wondering why Linq doesn't accept the perfectly good System.Predicate<T> instead of, or as well as, Func<T,bool>.

Is this a deliberate Linq style/design decision? Or am I missing something obvious about Func and Predicate?

Oli
  • 582
  • 1
  • 6
  • 18

1 Answers1

0

I'm wondering why Linq doesn't accept the perfectly good System.Predicate

Because they are semantically equivalent. There is no reason to take two overloads which do exactly the same. The advantage of (IMO) with Func is that it has several overloads taking more input types and returning any output type, while Predicate<T> is very limited.

Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321