tags:

views:

125

answers:

4

How reference types are stored on heap in .NET? (means in which form) If in application have 2 objects with same name how those objects will stored on heap?

+3  A: 

How Reference and Value types are stored in memory ?

rahul
Ick - the fact that it propagates the "value types are stored on the stack" myth in big bold letters puts me off instantly.
Jon Skeet
+5  A: 

Objects don't have names. The references (on the stack or as fields inside objects) have names and they refer to the objects. But 1 object can have more than 1 reference pointing to it.

Henk Holterman
+2  A: 

It doesn't mattery how they are stored; how they are stored is an implementation detail. You should be concerned with the observable characteristics of types, not implementation details. Further reading:

http://blogs.msdn.com/ericlippert/archive/2009/04/27/the-stack-is-an-implementation-detail.aspx

http://blogs.msdn.com/ericlippert/archive/2009/05/04/the-stack-is-an-implementation-detail-part-two.aspx

Greg Beech
A: 

The only relevant concern about how objects are stored, in most run-times, is that objects are streams of bytes, which might be contigious, and the primary knowledge about the objects is in code that manipulate references to it.

Cecil Has a Name