1.

Late Binding vs Early Binding in C#

Answer»

Details about Late Binding as well as Early Binding are given as follows:

  • Early Binding

The linking of a function with an object during compile TIME is HANDLED by early binding. Function overloading and operator overloading are the two main techniques that implement early binding.

  • Function Overloading

There are multiple definitions for the same function name in function overloading. All these definitions can differ by the number of arguments they contain or the TYPE of these arguments. The number and type of arguments passed are checked by the compiler at the compile time and on that basis a function is called. If there is no function that matches the parameter list at compile time, then an error is produced.

  • Operator Overloading

Many of the operators in C# can be overloaded such as unary operators (+, -, !, ++, --) , binary operators(+, -, *, /, %) etc. The functions that contain the keyword operator before the operator that is being overloaded are overloaded operators.

  • Late Binding

The linking of a function with an object during run time is handled by late binding. Late binding is implemented using abstract classes and virtual functions.

  • Abstract Classes

The base classes with PARTIAL implementation are known as abstract classes. These classes have virtual functions that are inherited by other classes to PROVIDE more functionality. The abstract methods in the abstract classes are implemented only in the derived classes. Also abstract classes cannot be instantiated.

  • Virtual Functions

Virtual functions are implemented in a different manner for different inherited classes i.e. they are redefined for the derived classes. The call to these virtual functions is decided at run time.



Discussion

No Comment Found