The var and dynamic are different.
keyword | Meaning |
---|---|
var | compiler would figure out the type |
dynamic | runtime would figure out the type |
To illustrate:
dynamic x = "hello"; // Static type is dynamic, runtime type is string var y = "hello"; // Static type is string, runtime type is string int i = x; // Runtime error (cannot convert string to int) int j = y; // Compile-time error (cannot convert string to int)
The static type of a variable declared with var can be dynamic:
dynamic x = "hello"; var y = x; // Static type of y is dynamic int z = y; // Runtime error (cannot convert string to int)