How Boxing and Unboxing Work for Dynamic DataType in C#

Viewed 2884

I know about boxing and unboxing concept of C# for Type conversion . But How It works for Dynamic Variable in C# . How Type conversion takes place when we use dynamic variable . In Which way it is following the boxing and unboxing principles of c#

I think boxing and unboxing does not treat Dynamic type as object as They are not same . Don't know whether they are following same mechanism for boxing and unboxing or not See this link dynamic vs object type

When you use dynamic, the entire expression is treated at compile time as a dynamic expression, which causes the compiler to treat everything as dynamic and get run-time binding.

this is because in below line str is dynamic

    dynamic str = "22/11/2013 10:31:45 +00:01";
    var withOffset = DateTimeOffset.Parse(str);

At compile time str is dynamic, the type of str get to know at runtime only that is the reason compiler treat withOffset as dynamic

1 Answers
Related