title: Storing a reference to an object in C#
body: <p>I was wondering how one could store a reference to an object in .net.</p>
  
  <p>That is, I would like something like the following code (note, of course, that the following code may be way off from how to actually do it):</p>
  
  <pre><code>class Test
  {
      private /*reference to*/ Object a;
      public Test(ref int a)
      {
          this.a = a;
          this.a = ((int)this.a) + 1;
      }
      public Object getA() { return this.a; }
  }
  /*
   * ...
   */
  static void Main(string[] args)
  {
      int a;
      a=3;
      Test t = new Test(ref a);
      Console.WriteLine(a);
      Console.WriteLine(t.getA());
      Console.ReadKey();
  }
  </code></pre>
  
  <p>To produce the following output:</p>
  
  <pre><code>4
  4
  </code></pre>
  
  <p>Ideally, I would like to do this without writing a wrapper class around the integer.</p>
  
  <p>In other words, I think I want pointers in .Net.</p>