Interface for Child Class that Inherits from parent class without reimplementing parent class

Currently I have the following:

public class ChildClass : ParentClass

ParentClass implements an interface as follows (I need ParentClass to be instantiated and therefore can’t be abstract):

public class ParentClass : IParentClass

I also want child class to implement an interface so that I can mock this class out, but I want the inherited members of ParentClass to be visible to the ChildClass Interface.

So if I have a method MethodA() in the parent class, I want this method to be able to be called when using IChildClass and not just ChildClass.

The only way I can think of is to override the method in the ChildClass, define that method in IChildClass and the just call base.MethodA() but this doesnt really seem correct

I hope this makes sense to yall

Source: oop

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.