title: How to share a variable between two classes?
body: <p>How would you share the same object between two other objects? For instance, I'd like something in that flavor:</p>
  
  <pre><code>class A
  {
     private string foo_; // It could be any other class/struct too (Vector3, Matrix...)
  
     public A (string shared)
     {
         this.foo_ = shared;
     }
  
     public void Bar()
     {
         this.foo_ = "changed";
     }
  }
  
  ...
  // inside main
  string str = "test";
  A a = new A(str);
  
  Console.WriteLine(str); // "test"
  a.Bar();
  Console.WriteLine(str); // I get "test" instead of "changed"... :(
  </code></pre>
  
  <p>Here, I don't want to give a ref to the Bar method. What I want to achieve is something that would look like that in C++:</p>
  
  <pre><code>class A
  {
    int* i;
  public:
    A(int* val);
  };
  
  A::A (int* val)
  {
    this-&gt;i = val;
  }
  </code></pre>
  
  <p>I read there is some ref/out stuff, but I couldn't get what I'm asking here. I could only apply some changes in the methods scope where I was using ref/out arguments...
  I also read we could use pointers, but is there no other way to do it?</p>