Follow by Email

Saturday, July 20, 2013

Example Late binding and early binding in .net | Difference between late and early binding in c#.net

1. Early binding

Early  Binding portrays that compiler knows what sort of object it is. (like intellisense which we get while writing the program here we see all the object methods know by the .net)

For example.

if we create object of any class and call any methods of that class that is early binding.

a)
 class add
{
  int addmethod(int z, int y)
 {
    return z+y;
 }

 void main()
 { 
  int value = add.addmethod(5,5);
 }

}

b) Function overloading is example for early binding.


2. late binding

Late Binding portrays that compiler does not realize what sort of object it is, what are all the methods and properties it holds. You need to declare it as an object, later you need get the type of the object, methods that are archived in it. Everything will be known at the run time. 

Example :

Function overriding is example for late binding.