Home > DeveloperSection > Forums > Difference between early binding and late binding in C#
Manoj Bhatt
Manoj Bhatt

Total Post:153

Points:1079
Posted on    January-26-2016 10:32 PM

 C# C#  .NET 
Ratings:


 1 Reply(s)
 350  View(s)
Rate this:
Hi All,
Please give me differential  points between early binding and late binding in c#.
thank you.


Anupam Mishra

Total Post:135

Points:949
Posted on    January-26-2016 11:28 PM

Here, these two topics are closely related to one most useful concept of OOP i.e. 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 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 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.
Here, some useful points of related then. These are:
1. Performance  will be better in early binding.
2. Application will run faster in Early binding, since no boxing or unboxing is done here but in late binding, we need type conversion as it will be decoded at run time.
3. Easier to write the code in Early binding, since the intelligence will be automatically populated .
4. Less chances of errors in early binding, as syntax is checked which flags error at compile time itself but for late binding there are chances of run time exceptions.
5. Late binding would support in all kind of versions, due to handing at run time.
Minimal impact of code in future enhancements, if late binding is used.

Don't want to miss updates? Please click the below button!

Follow MindStick