Reputation: 1968
Type checking for an Object
takes place at compile time where as type checking for dynamic
data type takes place at run time then how can we box a dynamic value into Object?
dynamic dynamic = "This is dynamic data type";
Object obj = dynamic;
Console.WriteLine(obj);
Upvotes: 5
Views: 358
Reputation: 1062780
dynamic
is already always an object
- it is essentially implemented as object
, with different rules on how invocation happens. So there's nothing to box between dynamic
and object
. Additionally, a string
literal is an object
, so: there's nothing to box there.
No boxing required here. You already have an object
. The implicit type conversion from dynamic
to object
is a no-op.
Upvotes: 9