title: C++/CLI passing a String ^ as a tracking reference doesn't work as expected
body: <p>I am using C++/CLI with VS 2010. Thanks to <a href="https://stackoverflow.com/a/3060012/3092979">this</a> answer I have learned that in C++/CLI you pass an object by reference like so </p>
  
  <pre><code>voin func(String ^ %string){
  //modify string
  }
  </code></pre>
  
  <p>What I want to do, is pass some arguments to a constructor of a <code>GetInput</code> form. Then modify them from the user input to this form. When the form closes, the caller form will get values entered in the <code>GetInput</code> form.</p>
  
  <p>And it worked for me with a <code>List&lt;double&gt;</code>, but not with a <code>String^</code>. Here is the code:</p>
  
  <pre><code>public ref class GetInput : public System::Windows::Forms::Form
  {
  public:
      List&lt;double&gt;^ _data;
      String ^ _string_data;
  
      GetInput(List&lt;double&gt;^ %data, String ^ %string_data){
          _data = data;
          _string_data = string_data;
          //this code is here just for the sake of an example, 
          //it's actually in one of the methods
          _data-&gt;Add(0.5); 
          _string_data = "15";
      }
      //void buttonClickHandler where i actually want to modify data and string_data
  }
  </code></pre>
  
  <p>The <code>List _data</code> gets modified, as well as the passed <code>data</code>, but when I modify the <code>String _string_data</code>, original <code>string_data</code> is left untouched. However if I modify the <code>string_data</code> itself - it works fine. Also, tracking reference can't be a member of the class, so declaring _string_data as a reference doesn't work.</p>
  
  <p>The obvious workaround would be to pass the <code>List^</code> consisting of one <code>String^</code>, but I would like to know why doesn't it work and if there is a way to make my approach work. Coming from native C++, this seemed like a pretty straightforward approach - just pass the pointer to the data. But C++/ClI tracking references are something different.</p>
  
  <p>Also I read that "A tracking reference is updated when the object moves on the garbage-collected heap." (<a href="https://msdn.microsoft.com/en-us/library/8903062a(v=vs.100).aspx" rel="nofollow noreferrer">source</a>). Can somebody clarify what this means? I suspect this contains an answer to my question, but I can't quite understand it:)</p>
  
  <p><strong>UPDATE:</strong>
  Basically I want to do this in C++/CLI:</p>
  
  <pre><code>class GetInput {
      string * s; 
      GetInput(string * caller_wants_this_modified){ 
          s = caller_wants_this_modified; 
      } 
      void method_to_modify_the_string(){ 
          (*s) = "New string value"; // modifies the string passed by the caller 
      } 
  }
  </code></pre>
  
  <p>I need to save the pointer passed to constructor as a class member and then change the data, this pointer points to, in one of the member functions.</p>