Dynamic and var data types difference

List out the difference between the “dynamic” and “var” data types?

E

Expert

Verified

The main difference between “dynamic” and “var” data types is that var data type is strongly type checked at the compile time; on the other hand, dynamic data type is type checked by compiler at run time.

After declaring a var data type, its type cannot be changed throughout the execution of the program; but, a variable of the dynamic data type can be changed during runtime.

Another important difference between the two is that dynamic type can be used as the return type for the methods, for which var cannot be used.

   Related Questions in DOT NET Programming

©TutorsGlobe All rights reserved 2022-2023.