There are 2 kinds of polymorphism static and dynamic. Many people also call them as runtime or compile time polymorphism.
Implementation of Static Polymorphism: -
Static polymorphism is implemented by using method overloading. In compile time itself we come to know if there are mismatches. Below code snippet shows how method overloading is implemented. The add method can take either 2 inputs or 3 inputs.
Depending on the number of inputs the addition logic is executed.
Implementation of Dynamic Polymorphism: -
Dynamic polymorphism is implemented by using overriding and virtual keyword.
Below is a simple code snippet which has three classes, Customer class is the parent class.CustomerDiscount10Percent and CustomerDiscount20Percent are child classes.
Customer parent class has a discount function which returns zero discounts. This function is defined as virtual and then overridden by both the child classes with 10 and 20% discount.
Now on the client side on the fly your parent object can point to any child classes and invoke the child implementation accordingly. This is called as dynamic polymorphism; the parent object can point to any of the child objects and invoke the child function dynamically.
Also see the following .NET interview questions video on polymorphism, static polymorphism and dynamic polymorphism: -