title: Converting Stream to String and back...what are we missing?
body: <p>I want to serialize objects to strings, and back.</p>
  
  <p>We use protobuf-net to turn an object into a Stream and back, successfully.</p>
  
  <p>However, Stream to string and back... not so successful. After going through <code>StreamToString</code> and <code>StringToStream</code>, the new <code>Stream</code>isn't
  deserialized by protobuf-net; it raises an <code>Arithmetic Operation resulted in an Overflow</code> exception.  If we deserialize the original stream, it works.</p>
  
  <p>Our methods:</p>
  
  <pre><code>public static string StreamToString(Stream stream)
  {
      stream.Position = 0;
      using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
      {
          return reader.ReadToEnd();
      }
  }
  
  public static Stream StringToStream(string src)
  {
      byte[] byteArray = Encoding.UTF8.GetBytes(src);
      return new MemoryStream(byteArray);
  }
  </code></pre>
  
  <p>Our example code using these two:</p>
  
  <pre><code>MemoryStream stream = new MemoryStream();
  Serializer.Serialize&lt;SuperExample&gt;(stream, test);
  stream.Position = 0;
  string strout = StreamToString(stream);
  MemoryStream result = (MemoryStream)StringToStream(strout);
  var other = Serializer.Deserialize&lt;SuperExample&gt;(result);
  </code></pre>