Can I somehow skip every third element using linq, starting at 1? those. 1, 4, 7 ...

There is such a sample, but you need to remove elements from it:

var links = doc.DocumentNode.SelectNodes("//table[@class='xml-feed-table']")[0].Descendants("tr") .Select(tr => tr.Elements("td").Select(td=> td.InnerHtml).ToList()).Skip(8).ToList(); 

    1 answer 1

    You can use the Where overload in which you can access the index of the current item, and remove unnecessary items, for example

     .Where((el,index)=>index % 3 != 1) 
    • @AlexKrass, so I did not say that we should not add to the existing one. But you have a strange formula - Grundy
    • Oh, it turns out there is an overload Where the index does not know. - VladD
    • @VladD, and then deleted something? approach has the right to life, given that not all methods are overloaded with the index - Grundy
    • No, index overload is infinitely better. - VladD
    • @Grundy, yes, I just did not look carefully at the formula and solution. You managed to intercept my deleted comment in 10 seconds. - Alex Krass