title: Is the variable that holds a reference to an object a value type?
body: <p>You've got a simple class:</p>
  
  <pre><code>public class foo {
      public object Property { get; set; }
  
      public void AMethod() {
          Property = new object();
          object x = Property;
      }
  }
  </code></pre>
  
  <p>As we know, the Property property has a hidden backing field that holds the object reference. The question is: is that backing field treated like a struct?</p>
  
  <p>What I mean is the memory for x allocated on the stack? Does it get garbage collected?  Or is it released when the method returns?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I'm responding here instead of in a comment because the text is too long to fit in a comment.</p>
  
  <p>I'm interested in x. I'm not aware of any class in the .Net framework called "ObjectReference". All anyone talks about is "I have a reference to an object", and you call the methods of the object using the reference. </p>
  
  <p>The fact is, the reference to the object and the object itself are not 1 &amp; the same thing. They both occupy different chunks of memory. When you pass an object to a method as a parameter, you're not passing the object but a reference to it. That reference is copied from an "ObjectReference" variable to the stack.</p>
  
  <p>References are extremely important. You can't manipulate an object without one; even "this" (or the implied "this" when you access the object's members inside of it) are really references to the particular chunk of memory that the object occupies.</p>
  
  <p>I don't think many people give any thought to references as separate entities. They're ubiquitous and you can't get anything done with objects without them.</p>
  
  <p>So what I'm trying to get at here is, if there were an ObjectReference class, would it be a struct? It seems like the memory for the reference itself is treated like a struct.</p>