Because Func<T, TResult>
is defined as
public delegate TResult Func<in T, out TResult>(T arg);
As you can see, the second parameter ( TResult
) is indeed covariant, but the first parameter ( T
, which is the input of the function) is actually contravariant (you can only feed it which is less pronounced).
Func<Employee, Person>
excellent because the window sill matches the signature, and Func<Person, Person>
fails because it is not.
See MSDN
source share