In C# there are two mechanisms for redefining or providing the new implementation of a method of parent class by its child class and these two mechanisms are known as Method overriding and Method hiding. Now on the basis of how method re-implementation is done we can distinguish between both of them.
Following are the important differences between Method Overriding and Method Hiding.
|Sr. No.||Key||Method Overriding||Method Hiding|
|1||Definition||Method Overriding is a mechanism to achieve polymorphism where the super class and sub class have same methods, including the parameters and signature and, when you call it using the sub class object, the implementation in the subclass is invoked.||On other hand Method Hiding can be defined as technique in which user can redefine the method of base or parent class using new keyword which results in hiding the main basic implementation provided by base class of that particular method.|
|2||Access of Parent implementation||In Method Overriding child class can access parent class method implementation.||In case of Method Hiding parent class method implementation cannot be accessed through child class reference.|
|3||Modifier Used||For Method overriding override keyword is being used.||In case of Method Hiding new keyword is used to define new implementation in child class.|
|4||Implementation type||In Method Overriding the implementation type of the method is of object type.||However on other hand implementation type of method in Method hiding is of reference type.|
|5||Parent to child reference||In Method Overriding when parent class reference variable is pointing to the object of the child class, then it will call the overridden method in the child class.||On the other hand in Method Hiding, when parent class reference variable is pointing to the object of the child class, then it will call the hidden method in the parent class.|
|6||Usage||Method Overriding only redefines the implementation of the method.||Method Hiding can completely redefine the method.|