What happens when a parent variable type stores a child object and invokes a method that was overridden by the child class?
Does the parent version of the method execute or does the child version of the method execute?
public class testa
{
public virtual void display()
{
System.Diagnostics.Debug.WriteLine('a');
}
}
public class testb : testa
{
public override void display()
{
System.Diagnostics.Debug.WriteLine('b');
}
}
then call somewhere
testa b = new testb();
b.display();
Through running this test on my own I found that it says "b", I would still like a formal answer though to fully understand what is happening.