如何将泛型约束添加到继承自其他类的C#类中
本文关键字:其他 类中 继承 泛型 约束 添加 | 更新日期: 2023-09-27 18:21:55
我正试图创建一个具有从另一个类继承的泛型约束的类——我遇到了编译错误:
public class BaseEntityController<T> where T : BaseEntity : BaseController
{
}
这段代码无法编译-我得到了"意外的令牌错误"。有办法做到这一点吗?
试试这个:
public class BaseEntityController<T> : BaseController where T : BaseEntity
{
}
怎么样
public class BaseEntityController<T> : BaseController where T : BaseEntity
{
}