[英]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.