Do you already have the contents of the file in StringBuilder?
It would be better to read line by line. Sort of:
private IEnumerable<string> GetLinesFromFile(string fileName)
{
using (var streamReader = new StreamReader(fileName))
{
string line = null;
bool previousLineWasBlank = false;
while ((line = streamReader.ReadLine()) != null)
{
if (!previousLineWasBlank && string.IsNullOrEmpty(line))
{
yield return line;
}
previousLineWasBlank = string.IsNullOrEmpty(line);
}
}
}
( ) :
foreach (var line in GetLinesFromFile("myFile.txt"))
{
Console.WriteLine(line);
}
. . : , iterator , foreach. ( , , ), , , .