【发布时间】:2011-10-05 06:27:39
【问题描述】:
我有一个接口,2类
public interface ITest
{
void Method1(){}
void Method2(){}
}
public class Test1 : ITest
{
//Just implement Method1() (how can I just implement Method1() without implementing Method2()?)
public string Method1()
{...}
}
public class Test2 : ITest
{
//Implement both Method1() & Method2()
public string Method1()
{...}
}
对于请求,我必须在接口中添加更多名为 Method3() 的方法,我的接口应该是:
public interface ITest
{
void Method1(){}
void Method2(){}
void Method3(){}
}
我必须将 Method3() 添加到类 Test1 和 Test2 中,我可以在需要时添加。
非常感谢
【问题讨论】:
-
一个实现接口的类需要实现所有方法,如果没有你需要检查抽象类也许这就是你需要的!