在Generic Class上添加继承类

时间:2014-10-07 04:04:33

标签: c# generics inheritance

我有这样的通用类:

public class MyClass<T> 
    where T : class
{
    // method in here...
}

我尝试让这个类继承自另一个类,如下所示:

public class MyClass<T> 
    where T : class
    : BaseMyClass
{
    // method in here...
}

但它不起作用。

是否可能从另一个类派生泛型类?以及如何做到这一点?

1 个答案:

答案 0 :(得分:4)

public class MyClass<T> : BaseMyClass where T : class
{
    // method in here...
}