1) Use new keyword when hiding base class's method in child class. 2) Can call base class's method in child class using base keyword. (base.ParentClassMethod) Or Cast it to Parent type: ((BaseClass) ChildClassObject). BaseClassMethod Or BaseClass baseClassObj = New ChildClass childclassobj baseClassObj.baseClassMethodname
Hello Venkat
ReplyDeleteWhat is a use of method Hiding?
1) Use new keyword when hiding base class's method in child class.
ReplyDelete2) Can call base class's method in child class using base keyword. (base.ParentClassMethod)
Or
Cast it to Parent type:
((BaseClass) ChildClassObject). BaseClassMethod
Or
BaseClass baseClassObj = New ChildClass childclassobj
baseClassObj.baseClassMethodname
Note: ChildClass childclassObj =New BaseClass Obj (WRONG!!!)
Brilliant explanation. Sums up the concept nicely.
Delete