When a child class inherits from both a parent class and an interface, why can the child class not access a parent class method?
Consider the following, where I can't access the DoSomething()
method.
class Program
{
static void Main(string[] args)
{
IMyInterface myClass = null;
myClass = new ChildClass();
// this returns error
myClass.DoSomething();
}
}
internal class ParentClass
{
public ParentClass() { }
public void DoSomething() { }
}
internal class ChildClass : ParentClass, IMyInterface
{
public string MyProperty { get; set; }
public ChildClass() : base() { }
}
internal interface IMyInterface
{
string MyProperty { get; set; }
}
I've looked through SO discussions here and here, but they seem to focus on how a member is hidden using new, override, and virtual keywords... sorry, but I can't figure out how that applies to this situation. Also, I've browsed through the MSDN API reference on interfaces here and here, with no luck.