Skip to content

Instantly share code, notes, and snippets.

@vbedegi
Created July 6, 2011 19:49
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 vbedegi/1068172 to your computer and use it in GitHub Desktop.
Save vbedegi/1068172 to your computer and use it in GitHub Desktop.
ReadLinesFromTextFile
@"c:\textfile.txt".ReadLinesFromTextFile().Where(x => x.Length > 10)
public static IEnumerable<string> ReadLinesFromTextFile(this string filename)
{
using (var reader = new StreamReader(filename))
{
string line;
while ((line = reader.ReadLine()) != null)
{
yield return line;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment