title: Setting the object to null without passing it as ref
body: <p>What's C# language specification for the following behavior. The values of the attributes are retained but the new instance (either null or new object) isn't updated to the actual parameter. It's basically functions as ref except changing the object it points to.</p>
  
  <p>The object in the main function remained intact (not null) but the string attribute has been changed to "Hello World"</p>
  
  <pre><code>class Program
  {
      class MyClass
      {
          public string str;
      }
  
      static void MyMethod(MyClass obj)
      {
          obj.str = "Hello World";
          obj = null;
      }
  
      static void Main(string[] args)
      {
          MyClass o = new MyClass();
          o.str = "Hello";
          Console.WriteLine(o.str);
          MyMethod(o);
  
          Console.WriteLine(o.str); // prints "Hello World"
      }
  }
  </code></pre>