考虑下面的接口,与默认的执行情况 TestMethod
public interface TestInterface
{
public int TestMethod()
{
return 15;
}
}
叫 TestMethod
在以下类将导致StackOverflowException:
public class TestClass : TestInterface
{
public int TestMethod()
{
return 1 + (this as TestInterface).TestMethod();
}
}
现在我明白这是为什么,但是否有任何方法去解决它吗? 喜欢的东西 base.TestMethod()
引用一个类的实现接口?
我知道我可以重新命名方法在TestInterface和参考它在TestClass这种方式,但是,这将导致问题的其他类别需要参照默认的执行情况。