Suppose I have
public static List Map(List inputs, Func f)
{
return inputs.ConvertAll((x) => f(x));
}
pr
The reason this does not work is for c# to do type inference on a method, it has to know the delegate type at the other end of the conversion. But at this point in time, the target delegate type is still not fully known - only T (int) is known, T2 is still unresolved.
Func f = Square;
//works because we provided the destination type
//of the conversion from Square to delegate
Map(inputs, i => Square(i));
//works because the lambda follows the actual method call
//and determines its own return type