0

Not much more than what the title says.

As I understand it, Predicate<T> (P) is literally identically equivalent to Func<T,bool>(F), and yet ... you can't jump between the two.

You can't pass a P in when a method expects an F, nor vice versa. You don't even seem to be able to explicitly cast between the two.

Is there a good reason for this? Or is this just something that got missed?


NOTE: I am not asking this question: Converting a Predicate<T> to a Func<T, bool>

I know how to get from one to the other ... I'm asking why they aren't the same/why there isn't an implicit cast defined, when they clearly could be.

Brondahl
  • 7,402
  • 5
  • 45
  • 74
  • dammit - I assumed that any matches would show up immediately when I googled my title :( – Brondahl Jul 27 '17 at 11:16
  • Is the done thing to delete the question, or something else? Is there an explicit "Yes I confirm that my question was a dupe?" button? – Brondahl Jul 27 '17 at 11:17
  • They're not the same, even though they look the same - if you get what I mean. If you have a class 'a' with integer property 'b', and you have class 'b' with integer property 'c' you can't implicitly cast to each other even though they look the same. Also, there is no `Func` that the compiler is aware of, only `Func`. I suppose this is the reason why they don't cast. I'm not sure about any exact details – bixarrio Jul 27 '17 at 11:18
  • 3
    @Brondahl, it's already been marked as a duplicate, so (assuming you're happy that the dupe is a dupe!), there's no need to delete your question yourself, the added terminology may help others find the answer they're looking for. In other words, a google search for your title will now give the answer you were looking for, thanks to this question =) – Rob Jul 27 '17 at 11:19
  • Ah, the duplicate actually says a lot more than I was aware of. Like Rob says; thanks for the question – bixarrio Jul 27 '17 at 11:22

0 Answers0