polymorphism
1. What is polymorphism?
Answer: It is an object, a variety of forms of behavior, that is, there are many ways (functions) to write, and there are many ways to call objects, such as rewriting, hiding, overloading, and interface
Second, what is the use of polymorphism?
Answer: Provide more choices, have more ways to reuse code, and improve maintainability
Polymorphism --- method hiding
1. What is method hiding?
Answer: It is one of the implementation methods of polymorphism, one of the writing methods (functions) in the class, and a technical concept
Second, what is the use of method hiding?
Answer: Selective reuse, to solve the problem that the method of the parent class is not suitable for the subclass
3. How to implement method hiding?
Answer: Define a method in the parent class, and then define a method with the same name and parameters in the subclass (this method can add "new")
Fourth, implement method hiding with C#
Five, the hidden characteristics of the method
There are two methods for subclasses to call the parent class, and inheritance is directly used for modification and later use
6. Disadvantages of the method
It is impossible to implement the parent class to call the subclass method, but the rewriting technology can
7. Summary:
Polymorphism provides more methods and object writing methods to improve code flexibility. One of the method hiding methods is to create a new method with the same name and parameters as the parent class, and then modify it to the desired content in the method body.