I have the interface IPet
and in another project I have the class Dog
which inherits from IPet
.
In Dog
I have the method Bark()
but not in IPet
.
In the project of IPet
I have also the class PetSimulation
in which I have an instance of IPet
.
Now I want to make something like this:
IPet myDog = new IPet("Rex");
myDog.Bark();
But IPet
does not have the method Bark()
and that should remain that way because other classes such as Cat
and Horse
are also inherit from IPet
but don't have the method Bark
either.
Also I can't do something like this:
Dog myDog = new Dog("Rex");
because Dog
is in another project.
Is there any way for me to call the Method Bark
of the subclass Dog
over the interface IPet
without implementing the method there?