title: Linq - lookahead Iteration
body: <p>I am iterating thru a collection using a visitor-type pattern and need to access the current and next item in the list. At the moment I am doing it via an extension method like this</p>
  
  <pre><code>public void Visit&lt;TItem&gt;(this IEnumerable&lt;TItem&gt; theList, Action&lt;TItem, TItem&gt; visitor)
  {
      for (i = 0; i &lt;= theList.Count - 1; i++) {
          if (i == theList.Count - 1) {
              visitor(theList(i), null);
          } else {
              visitor(theList(i), theList(i + 1));
          }    
      }    
  }
  </code></pre>
  
  <p>I was wondering whether there are other/better/more elegant ways to achieve this? At the moment I think I only need to have access to the current and next items in the list, but I'm wondering whether I may encounter situations where I may need to lookahead the next 'n' items, for example.</p>