Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top