On .net, value types are stored on the stack and reference types on the heap (and it's reference on the stack).

But if a variable is marked as dynamic, is this rule still valid based on the run-time type of the data?

I was looking for some reference that points to this, but didn't find any.

有帮助吗?

解决方案

A variable of type dynamic is a System.Object at runtime. So it is always a reference to an object that's stored on the GC heap. If you assign a value type value to the variable then it will be boxed with a standard boxing conversion.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top