We played with 4.0 DLR and compared the dynamics with the object and came across this:
the code:
object x = 10;
Console.WriteLine("x = {0} and is a {1}.\n", x, x.GetType());
x = (int)x + 3;
Console.WriteLine("x = {0} and is a {1}.\n", x, x.GetType());
x = x + "a";
Console.WriteLine("x = {0} and is a {1}.\n", x, x.GetType());
Result:
x = 10 and is System.Int32.
x = 13 and is System.Int32.
x = 13a and is System.String.
It seems to me that the object is trying to bind the object to a type at runtime (dynamic). However, if I don't pass x to int on the third line, this gives me a compiler area that seems correct for static input. But then it lets me add "a" to x, and now it recognizes it as a string.
What am I missing?
source
share