I wrote these helper functions a few weeks ago and I feel like I'm not taking advantage of some C# language features that would keep me from writing these same loops again for other similar helpers.
Can anyone suggest what I'm missing?
public static IList<string> GetListOfLinesThatContainTextFromList(
Stream aTextStream, IList<string> aListOfStringsToFind)
{
IList<string> aList = new List<string>();
using (var aReader = new StreamReader(aTextStream))
{
while (!aReader.EndOfStream)
{
var currLine = aReader.ReadLine();
foreach (var aToken in aListOfStringsToFind)
if (currLine.Contains(aToken))
aList.Add(currLine);
}
}
return aList;
}
public static DataTable GetDataTableFromDelimitedTextFile(
Stream aTextStream, string aDelimiter)
{
var aTable = new DataTable();
Regex aRegEx = new Regex(aDelimiter);
using (var aReader = new StreamReader(aTextStream))
{
while (!aReader.EndOfStream)
{
// -snip-
// build a DataTable based on the textstream infos
}
}
return aTable;
}