Skip to content

Instantly share code, notes, and snippets.

@lgolubyev
Created June 16, 2022 12:26
Embed
What would you like to do?
public IEnumerable<string> ReadFileLineByLine(string fileName)
{
if (string.IsNullOrEmpty(fileName))
{
throw new ArgumentNullException(nameof(fileName));
}
return ReadFileLineByLineImpl();
IEnumerable<string> ReadFileLineByLineImpl()
{
foreach (var line in File.ReadAllLines(fileName))
{
yield return line;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment