title: Setting a member variable to an object outside the class
body: <p>I want to track a variable in my class that was created outside the scope. In C++ i'd just pass a pointer like this.</p>
  
  <pre><code>class Camera
  {
      Player* player;
      Position pos;
  
      void setFollow(Player* pl) { pl = player; }
      void update() { pos = pl-&gt;getPos(); }
  }
  
  int Main()
  {
      Camera* camera = new Camera();
  
      Player* player = new Player();
  
      camera-&gt;setFollow(player);
  }
  </code></pre>
  
  <p>In C# I tried to pass by reference but it didnt seem to work.</p>
  
  <pre><code>public class Game1 : Microsoft.Xna.Framework.Game
  {
      Camera cam = new Camera();
      Player player = new Player();
  
      cam.setFollow(ref player);  // &lt;-- by reference
  }
  </code></pre>
  
  <p>This is just a shortened version of my actual code.</p>
  
  <p>Thanks for any help.</p>
  
  <p>EDIT: Thanks to all for the information. </p>