C# how do I loop this 10 times so it outputs the next 10 line sequences ?
using (var sr = new StreamReader(fileName))
{
string Start = File.ReadLines(FileName).Skip(14).First();
string End = File.ReadLines(FileName).Skip(14).last();
string sentence = Start + Environment.Newline + end;
}
using (var sr = new StreamReader(fileName))
{
// A loop to
iterate 10 times
for (int i = 0;
i < 10; i++)
{
//skip i * 10 lines for 10 times
string Start = File.ReadLines(fileName).Skip(14
+ i*10).First();
string End = File.ReadLines(fileName).Skip(14 +
i*10).last();
// get the sentence
string sentence = Start + Environment.NewLine +
End;
//output to console
Console.WriteLine(sentence);
}
}
Get Answers For Free
Most questions answered within 1 hours.