title: Why does MemoryStream Position property change with SetLength and become immutable?
body: <p>There's trouble using the System.IO.MemoryStream class.</p>
  
  <p>After creating it, like so:</p>
  
  <pre><code>var memory = new MemoryStream();
  </code></pre>
  
  <p>it then sets the length of some bytes to write into it.</p>
  
  <pre><code>var length = 181;
  memory.SetLength( length);
  </code></pre>
  
  <p>Then in the debugger, the memory shows the Length and
  Position BOTH set to 181.  In separate simply test program
  it property shows Position still at zero after <code>SetLength()</code>.</p>
  
  <p>Furthermore, if I change the <code>Position</code> property to 0 using
  the debugger or by adding a line of code, it ignores
  and still shows 181 as the position property.  Thus it 
  behaves as if immutable.</p>
  
  <p>However, again in a simple unit test, this works as expected.</p>
  
  <p>At first, this appeared to be a threading issue as
  if MemoryStream isn't thread safe.  But in the debugger,
  I froze all other threads before calling any of this code.
  And it still fails as above.</p>
  
  <p>Well, this is the most bizarre.  Any ideas what to try?</p>