Polymorphism means same operation can be defined in multiple forms.
There are two types of polymorphism:
Compile Time & Run-time polymorphism

Example of Compile Time polymorphism:- Method Overloading

It means having two or more methods having same name but different signature.
-the methods can be in the same class or different class (inherited).
-constructor overloading is also possible.
-it is not mandatory to have different return type, but either the number of parameters or parameters type should be different.

Example of Run time Polymorphism:- Method Overriding

Two or more methods with same signature but different implementation but in different class (base & inherited).

eg:- Using New & Override

1 Comment

Filed under C#

One response to “Polymorphism

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s