Given the following code:
interface IParent
{
void ParentPrintMethod();
}
interface IChild : IParent
{
void ChildPrintMethod();
}
class Baby : IChild
{
public void ParentPrintMethod()
{
Console.WriteLine("Parent Print Method");
}
public void ChildPrintMethod()
{
Console.WriteLine("Child Print Method");
}
}
All is well at this point. If you were to create a new instance of the Baby class as follows,
Baby x = new Baby();
everything is ok, and you would have access to the ParentPrintMethod() and the ChildPrintMethod();
However, can somebody please explain to me what would happen if you were to do the following?
IParent x = new Baby();
Would you have access to the ChildPrintMethod() in this case? What exactly is happening when you do this?