title: How to reuse a box?
body: <p>I'm writing some memory-sensitive code where for various reasons I must box some value types. Moreover, after some warm-up, I need net new heap allocations to be 0. After I've boxed <code>N</code> values, my algorithm needs no more storage, but these values must be updated frequently. I would like to be able to reuse the boxes already created on the heap.</p>
  
  <p>The following code suggests that boxes aren't reused (I can imagine why not). Is there different technique where I can reuse each box?</p>
  
  <pre><code>using System;
  
  public class Program
  {
      public static void Main()
      {
          object x = 42;
          object y = x;
          x = 43;
          bool isSameBox = Object.ReferenceEquals(x, y);
          Console.WriteLine("Same box? {0}.", isSameBox);
      }
  }
  
  // Output: "Same box? False."
  </code></pre>