Part 22 - C# Tutorial - Method hiding in C#


Part 22 - C# Tutorial - Method hiding


3 comments:

  1. Hello Venkat
    What is a use of method Hiding?

    ReplyDelete
  2. 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

    Note: ChildClass childclassObj =New BaseClass Obj (WRONG!!!)

    ReplyDelete
    Replies
    1. Brilliant explanation. Sums up the concept nicely.

      Delete

It would be great if you can help share these free resources