Skip to content

Instantly share code, notes, and snippets.

@lgolubyev
Created June 16, 2022 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgolubyev/599fb8351b32f2b7e8ec7c666297c548 to your computer and use it in GitHub Desktop.
Save lgolubyev/599fb8351b32f2b7e8ec7c666297c548 to your computer and use it in GitHub Desktop.
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