Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 ASP.Net 页面,需要实现我创建的接口类,但由于此页面中的代码是内联的,因此没有类声明,因此没有地方放置“Implements IMyInterface”行。我也尝试使用 @interface 页面指令,但它似乎只适用于内置的 .Net 框架类。
除了使用代码隐藏页面来编辑类声明行之外,还有其他选择吗?
您可以使用实施指令来做到这一点:
<%@ Implements Interface="MyNamespace.IMyInterface" %>
我不这么认为。您可以使用继承指令指定基类。您可以拥有一个派生自 Page 的类并在此类中实现接口。