Covariance and Contravariance with Func in generics

前端 未结 5 2013
夕颜
夕颜 2021-01-02 06:51

I need more information about variance in generics and delegates. The following code snippet does not compile:

Error CS1961 Invalid variance: The ty

5条回答
  •  礼貌的吻别
    2021-01-02 07:21

    Remove in and out -keywords from the interface definition:

    public interface Test{
        TOut F (Func transform);
    }
    

提交回复
热议问题