Professional Documents
Culture Documents
LoadChild:
public void Test(string s) -> 3
public override void Test(int x) -> 4
public void PTest(int x) -> 2
-After Overriding a method under the Child Class can we also consume the parent's
method from the Child ?
Note: If the object of the child class was assigned to the parents variable and
then if we invoke the overridden method, parent object also will invoke child
methods only, as it has given the permission for the child to override the method
it will give the preference to child methods.
-To test this re-write the following code under the Main method of the class
LoadChild.
LoadChild c = new LoadChild();
LoadParent p = c;
p.Test(10); //Calls Child Method
c.Test(10); //Calls Child Method
2. Using the base keyword also we can call the virtual methods of the parent
from the child class.
Note: using the base keyword is not allowed from static blocks like Main.