Introduction:
Here I will explain difference between early binding and late binding in c#.net with example or c#.net late binding vs early binding with example.
Description:
In
previous posts I explained OOPS examples in c#, polymorphism in c#, Difference b/w datareader, dataset and dataadapter in c#, Difference b/w appsettings and connection strings in asp.net,
Difference b/w executereader, executenonquery and executescalar
in c#, difference b/w view and stored
procedure in sql and many articles relating to interview questions in c#,
asp.net,
sql server, javascript,
jquery. Now I will explain Difference
between early binding and late binding in c#.net with example.
Early
Binding and Late Binding concepts occurred in polymorphism. First we will learn
about polymorphism
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
- Compile Time Polymorphism (Called as Early Binding or Overloading
or static binding)
- Run Time Polymorphism (Called as Late Binding or Overriding
or dynamic binding)
Compile Time Polymorphism or Early
Binding
Compile
time polymorphism means we will declare methods with same name but different
signatures because of this we will perform different tasks with same method
name. This compile time polymorphism also called as early binding or method
overloading.
Method
Overloading or compile time polymorphism means same method names with different
signatures (different parameters)
Run Time Polymorphism or Late Binding
Run
time polymorphism also called as late
binding or method overriding or dynamic polymorphism. Run time
polymorphism or method overriding means same method names with same signatures.
In
this run time polymorphism or method overriding 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. |
|||
|
|||
9 comments :
plz explain why we use commandbuilder class what is benefit of using commandbuilder class with example.
Thanks! It's just what I looking for...
hello. sir
late binding concept is wrongly explained.
Overloads and overrides have nothing to do with early or late binding.
Thank you very much. It is very simple and to the point Tutorial. again thank you very much.
Right or wrong i dont know but explain clearly........
ware we use static and dynamic binding in real time?
Very simple and well explained. but not sure it's correct logic or not. Some one please verify it.
Note: Only a member of this blog may post a comment.