C# generics contraints propagation

后端 未结 4 1740
小蘑菇
小蘑菇 2021-02-10 05:57

This example is a simplification of the real problem, but how can I get this to compile? I would expect the generics constraints to propagate.

Since T is a TClass and TC

4条回答
  •  没有蜡笔的小新
    2021-02-10 06:37

    For compiling this do;

    public void Func()
        where T :class, TClass
    {
        FuncA();
        FuncB();
    }
    

    because input of FunA is just a class not special class.

提交回复
热议问题