public override int Read ([In, Out] char[] dest_buffer, int index, int count)
{
if (base_stream == null)
throw new ObjectDisposedException ("StreamReader", "Cannot read from a closed StreamReader");
if (dest_buffer == null)
throw new ArgumentNullException ("dest_buffer");
if (index < 0)
throw new ArgumentOutOfRangeException ("index", "< 0");
if (count < 0)
throw new ArgumentOutOfRangeException ("count", "< 0");
// re-ordered to avoid possible integer overflow
if (index > dest_buffer.Length - count)
throw new ArgumentException ("index + count > dest_buffer.Length");
int chars_read = 0;
// while (count > 0)
{
if (pos >= decoded_count && ReadBuffer () == 0)
return chars_read > 0 ? chars_read : 0;
int cch = Math.Min (decoded_count - pos, count);
Array.Copy (decoded_buffer, pos, dest_buffer, index, cch);
pos += cch;
index += cch;
count -= cch;
chars_read += cch;
}
return chars_read;
}