If I have a class named \"Parent\"
for example. he has a method named \"Print\".
the class \"Kid\"
is derived, it has a method named
A virtual method call uses the actual type of the object to determine which method to call, while a non-virtual method uses the type of the reference.
Say that you have:
public class Parent {
public void NonVirtualPrint() {}
public virtual void VirtualPrint() {}
}
public class Kid : Parent {
public new void NonVirtualPrint() {}
override public void VirtualPrint() {}
}
Then:
Parent p = new Parent();
Parent x = new Kid();
Kid k = new Kid();
p.NonVirtualPrint(); // calls the method in Parent
p.VirtualPrint(); // calls the method in Parent
x.NonVirtualPrint(); // calls the method in Parent
x.VirtualPrint(); // calls the method in Kid
k.NonVirtualPrint(); // calls the method in Kid
k.VirtualPrint(); // calls the method in Kid