Reputation: 115
Consider the following interface, with a default implementation of TestMethod
public interface TestInterface
{
public int TestMethod()
{
return 15;
}
}
Calling TestMethod
in the following class will cause a StackOverflowException:
public class TestClass : TestInterface
{
public int TestMethod()
{
return 1 + (this as TestInterface).TestMethod();
}
}
Now I understand why this is, but is there any way to get around it? Something like base.TestMethod()
for referencing one of the class's implemented interfaces?
I know I could rename the method in TestInterface and reference it in TestClass that way, but that would cause problems for other classes that don't need to reference the default implementation.
Upvotes: 1
Views: 637