Difference between Var and Dynamic Keywords

In this blog you will see the difference between Var and Dynamic keywords.

Many developers are very confused about how to differentiate between var and dynamic keyword.
Let's try to understand.

Open a New Project Like:


var _string = "Amit Kumar";


Here I defined a var type variable which contains string value.

And I want to get the length of this string here.


After that one more point here please pay attention (above screen shot) when we type the length property then it shows (local variable) string _string . It means _string is string data type. Due to this reason it is called early bounded .

Dynamic keyword:


In the above snippet I defined dynamic type d and store “Abhishek” after that get the length of dynamic type variable d when we type d.length then you can see he does not know what is data type of d .


Still it is not pointing out that it is string data type or other data type.

After that gets the name and length of dynamic data type shown like.


When we type d.Length, d is still here and we do not know whether d has length property or not;  it dynamically (runtime)goes and uses reflexation and uses Length property.

Due to this reason dynamic is known as late bounded,


When we typed d.length it brought exception because length is written with a small letter and it is not a property of string.


Conclusion : Var is early bounded, dynamic is late bounded.