Why does 'Func<IBase>' compile while 'Func<TGeneric> where TGeneric : IBase' doesn't?
问题 Why is the following bloc wrong? public interface IBase { } public class ClassX : IBase { } public class ClassY { public static ClassX FunctionReturnX() { return new ClassX(); } } public class ClassZ<TGeneric> where TGeneric : IBase { Func<IBase> funcInterface = ClassY.FunctionReturnX; //Right Func<TGeneric> funcGeneric = ClassY.FunctionReturnX; //Wrong } 回答1: In summary, you cannot cast ClassX to any class that implement IBase . You are only guaranteed to be able to cast it to IBase itself.