What is the difference between overloading and overriding in c#?

Polymorphism

Polymorphism means many forms (ability to take more than one form). In Polymorphism poly means “multiple” and morph means “forms” so polymorphism means many forms.

In polymorphism we will declare methods with same name and different parameters in same class or methods with same name and same parameters in different classes. Polymorphism has ability to provide different implementation of methods that are implemented with same name.

In Polymorphism we have 2 different types those are

       –  Overloading (Called as Early Binding or Compile Time Polymorphism or static binding)

       –  Overriding (Called as Late Binding or Run Time Polymorphism or dynamic binding)

Overloading

Overloading means we will declare methods with same name but different signatures because of this we will perform different tasks with same method name. This overloading also called as compile time polymorphism or early binding.

Method Overloading or compile time polymorphism means same method names with different signatures (different parameters)

For more details check this link polymorphism in c#

Overriding

Overriding also called as run time polymorphism or late binding or dynamic polymorphism. Method overriding or run time polymorphism means same method names with same signatures.

In this method overriding or run time polymorphism we can override a method in base class by creating similar function in derived class this can be achieved by using inheritance principle and using “virtual &override” keywords.

http://pramadha.com/

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s