title: Read MemoryStream into Byte[] chunk at a time for processing
body: <p>I am passing a MemoryStream to a function - this could potentially end up being very large in size. This then needs to be split off into a small byte[] for processing and then added back to a stream. In my previous implementation I had roughly the following:</p>
  
  <pre><code>byte[] output = new byte[stream.Length];
  output = stream.ToArray();
  byte[] processingArray = new byte[16];
  
  int index = 0;
  int chunks = output / 16;
  for(int i = 0; i &lt; chunks; i++){
    for(int x = 0; x &lt; 16; x++){
       processingArray[x] = output[x + index];
    }
    //do the processing on the array here
    index += 16;
  }
  </code></pre>
  
  <p>I want to avoid having to use .ToArray() as this seems like a resource waste to me.
  How would I go about extracting 16 bytes at a time from the memorystream, processing it and then grabbing the next 16 bytes?</p>
  
  <p>Thanks</p>