Created
July 6, 2011 19:49
-
-
Save vbedegi/1068172 to your computer and use it in GitHub Desktop.
ReadLinesFromTextFile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@"c:\textfile.txt".ReadLinesFromTextFile().Where(x => x.Length > 10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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