Using static method from generic class

后端 未结 4 797
陌清茗
陌清茗 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条回答
  •  萌比男神i
    2021-01-27 13:41

    It's not possible to do exactly what you're asking, but since the method doesn't use T at all, you can just use BaseFactory.UpdateDataBase_static(); without specifying any particular class.

    But as an editorial comment, in general a method in a generic class that never uses the generic parameter probably shouldn't be there.

    提交回复
    热议问题