我有课
class ManagerCar : IBlalba
{
public void Render(IViewTemplate template)
{
}
}
我知道参数模板是什么CarViewTemplate
我希望检查类型并在IViewTemplate != CarViewTemplate
我可以查看if(template is typeof(CarViewTemplate))
。
但我有很多Managers
。
我希望在编译时检查此类型,并使用[IsType(typeof(CarViewTemplate))]
有可能吗?
更新
我有Render(IViewTemplate template)
答案 0 :(得分:2)
这种类型的检查已经存在于编译器中,无需尝试帮助它。
只需将您的方法签名更改为:
public void RenderCar(CarViewTemplate template)