The term "polymorphism" was first used in biology, meaning that organisms of the same race had the same characteristics.
In C #, polymorphism is defined as the same operation acting on instances of different classes, and different classes will be interpreted differently, resulting in different execution results. C # supports two types of polymorphism:
Compile-time polymorphism
Compile-time polymorphism is accomplished by overloading. In the 11th chapter, we introduce the operator overload of method overload, all of which achieve the compile-time polymorphism.
For a non-virtual member, the system determines what to do at compile time based on information such as the parameters passed, the type of return, and so on.
Run-time polymorphism
Run-time polymorphism refers to what happens when the system is run and what is done according to the actual situation. In C #, Run-time polymorphism is implemented by virtual members.
Compile-time polymorphism provides us with fast running characteristics, while Run-time polymorphism brings a high degree of flexibility and abstraction.