Baffled.
class Test
{
void Main()
{
F(() => ""); // ok
F(named: () => ""); // 'T' cannot be inferred from the usage!
F<string>(() => ""); // ok
F<string>(named: () => ""); // ok
}
void F<T>(Func<T> named) { }
}
Could someone tell me why the second call to F fails to compile?
(Note that this is a significantly stripped down example, which is why it seems synthetic. In the real case I came across, there are some default parameters before 'named' and so the named parameter is required. And so, apparently is explicit specification of 'T' by the caller.)
Seems like an inadequacy in the compiler's delegate type inference...sorry I can't offer more.
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