Write and write polymorphism first:
Inheritance: When subclasses inherit the parent class, subclasses can use it without redefining the methods in the parent class.
Polymorphic: When subclasses override methods of the parent class. The object of the parent class, when calling a method of a subclass, chooses the method of the base class, depending on the situation.
In a nutshell, the subclass inherits the methods obtained by the parent class, which can be overridden by overrides, so that an instance of the parent class can use the subclass's methods.
Enclose the code to bring in the explanation:
This is a succession of fruits and their methods under fruit.
Output results above
Part II: Usage of this
Here this defines the member of the employee category that is hidden by a similar name, name and alias. It is also used to transfer objects to Calctax, a method that belongs to other classes.
This is the result of the output:
C # (3) Usage of--this and polymorphism in C #