public int ReadLine (char [] buffer, int index, int count)
{
if (Disposed)
throw new ObjectDisposedException ("StreamLineReader");
if (buffer == null)
throw new ArgumentNullException ("buffer");
if (index < 0)
throw new ArgumentOutOfRangeException ("index", "< 0");
if (count < 0)
throw new ArgumentOutOfRangeException ("count", "< 0");
// ordered to avoid possible integer overflow
if (index > buffer.Length - count)
throw new ArgumentException ("index + count > buffer.Length");
int len = 0;
while (len < count) {
if (n == max) {
max = sr.ReadBlock (buff, 0, buff.Length);
n = 0;
if (max == 0)
return len;
}
char c = buff [n++];
switch (c) {
case '\r':
continue;
case '\n':
Array.Clear (buffer, len, buffer.Length - len);
return len;
default:
buffer [index++] = c;
len++;
break;
}
}
return len;
}