What is static and dynamic binding?

Asked 07-Dec-2019
Viewed 1422 times

1 Answer


0

Whenever an object is assigned to an object variable of the specific type, then the C# compiler performs the binding with the help of .NET Framework. C# performs two different types of bindings which are:

  • Early Binding or Static Binding
  • Late Binding or Dynamic Binding

Early Binding or Static Binding

These are recognizes and checks the methods, or properties during compile time. According to this binding, the compiler already knows about what kind of object it is and what are the methods or properties it holds, here the objects are static objects. The excecution of early binding is fast and it is easy to code. It decreases the number of run-time errors.

What is static and dynamic binding?

Late Binding or Dynamic Binding

About the LateBinding, the compiler does not know about what kind of object it is and what are the methods or properties it holds, here the objects are dynamic objects. When the type of the objects are decided on the basis of the data that holds on the right-hand side during run-time. Mostly, the late binding is achieved by using virtual methods. The excecution of late binding is slower than early binding because it requires lookups at run-time.

What is static and dynamic binding?

Please Read :- What is virtual function?