Question

I have the following IEnumerable:

var lines = File.ReadLines(this.FileToExtract); // IEnumerable<string>

Now I want to exclude the first 3 lines using linq, What should I do? Thanks.

Was it helpful?

Solution

Use Skip.

var linesTest = lines.Skip(3);

To take all but last:

var allButLast = linesTest.Take(linesTest.Count() - 1);

OTHER TIPS

var lines = File.ReadLines(this.FileToExtract).Skip(3);

Use Skip:

var lines = File.ReadLines(this.FileToExtract).Skip(3);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top