c# - 在通用类上添加继承类

标签 c# generics inheritance

我有这样的通用类:

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

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

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

但是没有成功。

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

最佳答案

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

关于c# - 在通用类上添加继承类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26228379/

相关文章:

python - 在运行时扩展一个实例

c# - Entity Framework 构建退出并出现警告,并且在克隆 CodePlex 存储库后不会运行测试

c# - 根本不调用 ASP.MVC IUserRoleStore<>

generics - 带有通用列表的 Groovy CompileStatic

c# - (Action<T>).Name 不返回预期值

generics - 是否可以约束在 jsDoc @template 声明中定义的泛型类型?

c# - 将 Ctrl+Z 发送到串行端口

c# - 如何使用 Control.Dispatcher.BeginInvoke 修改 GUI

ruby - 为什么 Ruby 模块包含排除了模块的单例类?

c# - 从基类调用事件