【发布时间】:2011-04-17 12:26:23
【问题描述】:
我有以下界面
interface ITest
{
void TestVoid();
}
class A : ITest
{
public void ITest.TestVoid() //will not work
{
Conole.WriteLine("Done");
}
public void TestVoid() //without name of interface, it works
{
Conole.WriteLine("Done");
}
}
第二个问题:接口只包含成员签名但不包含实现是否正确?
【问题讨论】:
-
关于问题的标题,如果您希望提供默认实现,请查看使用抽象类。两者之间存在差异,因此您需要研究哪个适合您的需求。或者,this question 使用抽象类和接口。
标签: c# .net inheritance interface