0

Method hiding

what is the diffrence between method hiding and method overriding?

5th Oct 2017, 10:43 AM
Adarsh Srivastava
Adarsh Srivastava - avatar
3 Réponses
+ 5
is this any type of question?? i think u shouldn't post that kind of thing ask something that help to other people hope u understand.. make better sololearn ☺
5th Oct 2017, 10:59 PM
Scooby
Scooby - avatar
+ 6
For hiding the base class method from derived class simply declare the derived class method with the new keyword. Whereas in C#, for overriding the base class method in a derived class, you need to declare the base class method as virtual and the derived class method as overridden. If a method is simply hidden then the implementation to call is based on the compile-time type of the argument "this". Whereas if a method is overridden then the implementation to be called is based on the run-time type of the argument "this". New is reference-type specific, overriding is object-type specific.
7th Oct 2017, 9:28 AM
Scooby
Scooby - avatar
0
I learnt about the diffrences between these 2 terms. what I found is in case of method overriding the method should be object type or non static method. whereas in case of method hiding, method must be static on both parent and child classes.
7th Oct 2017, 9:25 AM
Adarsh Srivastava
Adarsh Srivastava - avatar