I have the following code:
public static class X
{
public static C Test<A,B,C>(this A a, Func<B,C> f)
where C:class
{
return null;
}
}
public class Bar
{
public Bar()
{
this.Test(foo); //this doesn't compile
this.Test((Func<int, string>)foo);
this.Test((int q) => "xxx");
}
string foo(int a) { return ""; }
}
Why doesn't the marked line compile? Does it have something to do with return type not being part of the signature?
But the third line does compile, which makes me guess the compiler turns it into something similiar to the second line...