/// <summary> /// Copies part of lines of the current <see cref="TextReader"/> object to a <see cref="TextWriter"/> object. /// </summary> /// <param name="readers">The current <see cref="TextReader"/> object.</param> /// <param name="output">The output <see cref="TextWriter"/> object.</param> /// <param name="offset">Provides the current-postion based index of the line where the copy starts. If this argument is set 0, the copy starts from the current position of the <see cref="TextReader"/> object.</param> /// <param name="lineCount">The number of lines to copy.</param> /// <exception cref="System.ArgumentNullException"> /// Occurs when either <paramref name="reader"/> or <paramref name="output"/> is <c>null</c>. /// </exception> public static void CopySublines(this TextReader reader, TextWriter output, int offset, int lineCount) { if (lineCount <= 0) { return; } if (reader == null) { throw new ArgumentNullException("reader"); } if (output == null) { throw new ArgumentNullException("output"); } reader.Advance(offset); while (lineCount != 0) { output.WriteLine(reader.ReadLine()); --lineCount; } }