title: How is the Stream.CopyTo(Stream) method implemented in .NET 4?
body: <p>A useful convenience introduced in .NET 4 is <strong><a href="http://msdn.microsoft.com/en-us/library/system.io.stream.copyto(VS.100).aspx" rel="nofollow noreferrer">Stream.CopyTo(Stream[, Int32])</a></strong> which reads the content from the current stream and writes it to another stream.</p>
  
  <p>This obviates the need for slightly tedious <a href="https://stackoverflow.com/questions/230128/best-way-to-copy-between-two-stream-instances-c">code such as this</a>:</p>
  
  <pre><code>public static void CopyStream(Stream input, Stream output)
  {
      byte[] buffer = new byte[32768];
      while (true)
      {
          int read = input.Read (buffer, 0, buffer.Length);
          if (read &lt;= 0)
              return;
          output.Write (buffer, 0, read);
      }
  }
  </code></pre>
  
  <p>Since I don't have .NET 4 installed on this machine, I was wondering if someone who has .NET 4 installed could open up Reflector and show us how the Framework Class Library team implemented this method for .NET 4.</p>
  
  <p>Compare and contrast their implementation with code snippet above. In particular, I'm interested to know what default buffer size was chosen.</p>