Where are value types defined in a reference type stored (heap or stack)?

The only variables stored on the stack are local variables for a function. For reference types, the reference is stored on the stack while the object it refers to is stored on the heap. For value types, the object itself is stored on the stack. Note that local variables that can escape from the local function (such as via a closure) are stored in a separate data structure on the heap, including any value types that may be included.

In other words, since reference types are always stored on the heap, anything they contain (even value types) is also stored on the heap.


Memory in .NET - what goes where by Jon Skeet