Using static method from generic class

后端 未结 4 789
陌清茗
陌清茗 2021-01-27 13:10

I have problem as above. My code:

public abstract class BaseFactory where T: class
{
    protected static dbModelContainer context = new dbModelContaine         


        
4条回答
  •  無奈伤痛
    2021-01-27 13:27

    You don't.

    You always need to supply the generic type arguments when accessing a class, even though you aren't using that type argument in your method. Since you don't actually use the generic type in the method it means you could move that method out of that class, and into one that isn't generic, but for as long as it's in that class you'll need to supply the generic argument.

提交回复
热议问题