title: MemoryStream disables reading when returned
body: <p>In my program, I am basically reading in a file, doing some processing to it, and then passing it back to the main program  as a memorystream, which will be handled by a streamreader.  This will all be handled by a class beside my main.</p>
  
  <p>The problem is, when I return the memory stream from my method in another class, the "canread" variable is set to false, and thus causes the streamreader initialization to fail.</p>
  
  <p>Below is an example of the problem happening (though in here I'm writing to the memorystream in the other class, but it still causes the same error when i pass it back.</p>
  
  <p>In the class named "Otherclass":</p>
  
  <pre><code>public static MemoryStream ImportantStreamManipulator()
  {
     MemoryStream MemStream = new MemoryStream();
  
     StreamWriter writer = new StreamWriter(MemStream);
     using (writer)
     {
         //Code that writes stuff to the memorystream via streamwriter
  
         return MemStream;
     }
  }
  </code></pre>
  
  <p>The function calls in the main program:</p>
  
  <pre><code>MemoryStream MStream = Otherclass.ImportantStreamManipulator();
  StreamReader reader = new StreamReader(MStream);
  </code></pre>
  
  <p>When I put a breakpoint on the "return MemStream", the "CanRead" property is still set to true.  Once I step such that it gets back to my main function, and writes the returned value to MStream, the "CanRead" property is set to false.  This then causes an exception in StreamReader saying that MStream could not be read (as the property indicated).  The data is in the streams buffer as it should be, but I just can't get it out.</p>
  
  <p>How do I set it so that "CanRead" will report true once it is returned to my main?  Or am I misunderstanding how MemoryStream works and how would I accomplish what I want to do?</p>