![](/img/trans.png)
[英]How to write nunit test case(c#) for generic class which inherits another class
[英]How to Add Generic Constraint to C# class which inherits from other class?
我正在尝试创建具有从另一个类继承的泛型约束的类-我遇到了编译错误:
public class BaseEntityController<T> where T : BaseEntity : BaseController
{
}
此代码无法编译-我收到“意外的令牌错误”。 有没有办法做到这一点?
尝试这个:
public class BaseEntityController<T> : BaseController where T : BaseEntity
{
}
怎么样
public class BaseEntityController<T> : BaseController where T : BaseEntity
{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.