【发布时间】:2016-11-22 01:04:36
【问题描述】:
界面是:
public interface CommonPluginInterface
{
string GetPluginName();
string GetPluginType();
bool ElaborateReport();
}
现在我希望所有派生类通过字符串和枚举来标识自己。对于字符串,它很容易被硬编码:
public class PluginReport_Excel : MarshalByRefObject, CommonPluginInterface
{
public string GetPluginName()
{
return "Foo";
}
}
但另外我希望它也通过枚举来识别。于是想着把接口放进去,但是接口不能包含成员。
所以我想到了制作
public class CommonPluginClass
{
private enum ePluginType { UNKNOWN, EXCEL, EXCEL_SM, RTF}
private ePluginType pluginType;
}
并让派生类也从中派生,但这是不可能的,因为它说:
“PluginReport_Excel”类不能有多个基类:“MarshalByRefObject”和“CommonPluginClass”
我需要 MarshalByRefObject。 感谢您的帮助。
【问题讨论】:
标签: c# inheritance interface derived-class