Skip to content
Discussion options

You must be logged in to vote

Aren't all delegates with matching parameter types supposed to be convertable to each other?

No, delegates are nominal types and not convertible between each other regardless of their signature. The natural type for a method group will be one of the Action<...> or Func<...> delegate families if compatible, otherwise the compiler will emit a compatible delegate type with an unspeakable name. That is why V1 contains a single method, the natural delegate type for method Test3 is Func<string, string, CancellationToken, IAsyncEnumerable<string>>. But even though that delegate has the same signature as InvokeMethod1 and InvokeMethod2 it is not considered the same type and cannot be cast to th…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TonyValenti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants