Why doesn't this C # code compile when using named parameters?
Upset.
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) { }
}
Can someone tell me why the second call to F will not compile?
(Note that this is a significantly truncated example, so it seems synthetic. In the real case, when I came across, there are some default parameters before "named", and therefore a named parameter is required. Explicit specification of the "T" of the caller.)
+5