title: Am I setting the value of the reference when changing a field of my class, or just the value of a value?
body: <p>I am writing a piece of code which involve a lot of duplication of data and operations and it is important to me that I minimise this as much as possible. The <a href="https://msdn.microsoft.com/en-us/library/8b0bdca4.aspx" rel="nofollow">MSDN support doc</a>, to me, implies that when I set the field of my class <code>Foo</code> as an instance of some class <code>Bar</code> I am setting this as a reference to this instance, rather than the value, which is exactly what I want to do. Given how important this feature is to me however (it will affect the runtime of my program by orders) could someone wiser please confirm for me.</p>
  
  <p>Code example:</p>
  
  <pre><code>public class Foo
  {
      public Bar ChildBar {get;set;}
  
      public void SetChildBarValue (int value)
      {
          this.ChildBar.Value = value;
      }
  }
  
  public class Bar
  {
      public int Value {get;set;}
  }
  
  var foo1 = new Foo();
  var foo2 = new Foo();
  var bar = new Bar();
  
  foo1.ChildBar = bar;
  foo2.ChildBar = bar;
  
  foo1.SetChildBarValue(1);
  Console.WriteLine(foo2.ChildBar.Value);
  </code></pre>
  
  <p>My question is, will the <code>WriteLine</code> return <code>1</code> or <code>null</code>?</p>
  
  <p>Thanks in advance.</p>