Types of polymorphism

In C#, we have two types of polymorphism and these types are:

  • Compile-time polymorphism

Compile-time polymorphism is also famous as early binding or overloading or static binding. It determines at compile-time and meant for same function name with different parameters. Compile-time or early binding is further divided into two more types and these types are:

    • Function Overloading

Function overloading as name is self-explanatory function is overloaded. When you declare function with same name but different parameters, it is called as function overloading. You can declare as many overloaded functions as you want.

Consider following code-snippet:

public class Math{ public int Add(int num1, int num2) => num1 + num2; ...

Get Learn C# in 7 days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.