title: Select even/odd elements in IEnumerable<T>?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/267033/getting-odd-even-part-of-a-sequence-with-linq">Getting odd/even part of a sequence with LINQ</a><br>
    <a href="https://stackoverflow.com/questions/682615/how-can-i-get-every-nth-item-from-a-listt">How can I get every nth item from a List&lt;T&gt;?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm using HtmlAgilityPack and C# to parse some HTML.</p>
  
  <pre><code>&lt;div id="post-8266"&gt;
  &lt;div class="ruler"&gt; &lt;/div&gt;
  &lt;div id="post-8266"&gt;
  &lt;div class="ruler"&gt; &lt;/div&gt;
  &lt;div id="post-8266"&gt;
  &lt;div class="ruler"&gt; &lt;/div&gt;
  &lt;div id="post-8266"&gt;
  &lt;div class="ruler"&gt; &lt;/div&gt;
  </code></pre>
  
  <p>Basically, I have these elements, each in their own object, inside of an IEnumerable.</p>
  
  <p>Is there an elegant way to get each N/2 element in the collection. Meaning, skip over each div with class <code>.ruler</code>? </p>
  
  <p>I would need to iterate through the resulting set, so either I copy each found object into a new IEnumerable or just use it inline in a foreach function.</p>
  
  <p>For example:</p>
  
  <pre><code>//Copying resulting set to new IEnumerable&lt;T&gt;:
  var odds = elements.SelectOdds();
  
  //Using it inline for my usage:
  foreach (var x in elements.SelectOdds())
  {   
  }
  </code></pre>
  
  <p>Which options would be best, and how can I achieve this elegantly?</p>