Created
February 3, 2015 03:26
-
-
Save Mooophy/38873a45c4e40d251bde to your computer and use it in GitHub Desktop.
example for making reading line as Enumerable
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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Linq.Expressions; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| using System.IO; | |
| namespace JuestForCshap | |
| { | |
| class Program | |
| { | |
| static IEnumerable<string> ReadFrom(string file) | |
| { | |
| using (var reader = File.OpenText(file)) | |
| for(string line; (line = reader.ReadLine()) != null;/* */) | |
| yield return line; | |
| } | |
| static void Main(string[] args) | |
| { | |
| foreach (string line in ReadFrom(@"d:\test_enrol.csv")) | |
| Console.WriteLine(line); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment