Introduction:
Here I will explain difference between overloading and overriding in c#.net with example or c#.net overloading vs. overriding with example.
Description:
In
previous posts I explained sealed class in c#, using statement in c#, OOPS examples in c#, difference b/w array and arraylist in
c#,
difference b/w constant and readonly in
c#,
difference b/w view and stored
procedure in sql, difference between wcf and web
application,
interview questions in asp.net, sql
server, c#
and many articles relating to interview questions in c#,
asp.net,
sql server, javascript,
jquery. Now I will explain Difference
between overloading and overriding in c#.net with example.
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)
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.
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
22 comments :
Muito bom os conceitos, de polimorfismo....
simply superb
Nice
Nice Friend Thank ya sou much short, quick and help full :-)
Awesome thanks..!
super machee
Nice One
it is very good.
if it has one emample it would be superb
good one
Really helpful site for Asp.net begineers , Thanks Suresh :)
Nice one ...!
but lake of example otherwise so good dear.
Great. Thank u
Awsum def
Hi , Can you please explain when to use Method overriding with a real time example which u used in any project.
great....!
Thank u
Very Good
nice
Short and sweet
short and perfect .Thank you...it is very helpfull
good one.
Note: Only a member of this blog may post a comment.