Skip to content

Instantly share code, notes, and snippets.

@Mooophy
Created February 3, 2015 03:26
Show Gist options
  • Select an option

  • Save Mooophy/38873a45c4e40d251bde to your computer and use it in GitHub Desktop.

Select an option

Save Mooophy/38873a45c4e40d251bde to your computer and use it in GitHub Desktop.
example for making reading line as Enumerable
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