Haven't fired up reflector to look at the difference but would one expect to see the exact same compiled code when comparing Func<T, bool>
vs. Predicate<T>
I would imagine there is no difference as both take a generic parameter and return bool?
They share the same signature, but they're still different types.
Robert S. is completely correct; for example:-
class A { static void Main() { Func<int, bool> func = i => i > 100; Predicate<int> pred = i => i > 100; Test<int>(pred, 150); Test<int>(func, 150); // Error } static void Test<T>(Predicate<T> pred, T val) { Console.WriteLine(pred(val) ? "true" : "false"); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With