I have the method below which uses Yield Return to read large ( >1m ) lines of text from a file.
private static IEnumerable<string> ReadLineFromFile(TextReader fileReader)
{
using (fileReader)
{
string currentLine;
while ((currentLine = fileReader.ReadLine()) != null)
{
yield return currentLine;
}
}
}
I need to be able to write every 10 lines returned from this method to different files.
How do I consume this method without enumerating all the lines?
Any answer is very much appreciated.