1
0
oop-1-labs/Lab4/Lab4.ChainedWords/InOut.cs

28 lines
698 B
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Lab4.ChainedWords
{
static class InOut
{
/// <summary>
/// Read a file line-by-line using an enumarable
/// </summary>
/// <param name="filename">Target file</param>
/// <returns>Enumerable</returns>
public static IEnumerable<string> ReadByLines(string filename)
{
string line;
using (StreamReader reader = new StreamReader(filename))
{
while ((line = reader.ReadLine()) != null)
{
yield return line;
}
}
}
}
}