我有这样的通用类与通用类型的条件#类的限制:下与泛型类型参数
public abstract class ReportModel<ReportHandler> where ReportHandler : IReportHandler
然后,我有这个控制器类
public abstract class ReportController<ReportModelType> : Controller
我需要的是一个条件, ReportModelType必须继承类的摘要ReportModel类。麻烦的是,Im然后强制给出一个ReportModel的类型参数,我不想指定参数。我需要这样的通配符:
public abstract class ReportController<ReportModelType> : Controller where ReportModelType : ReportModel<*any type which satifies ReportModels contraint>
任何人都可以提供解决方案吗?
你是什么意思,你被迫提供一个类型参数?我不太明白那部分 – nocodename
只要我写*其中ReportModelType:ReportModel *我会得到一个错误,说我必须为ReportModel提供一个类型参数 –