title: Efficient list self compare in LINQ?
body: <p>This may be very similar to this <a href="https://stackoverflow.com/questions/823109/how-do-i-create-a-linq-query-that-gets-everything-but-a-specific-value">question</a> but I would like to know the most efficient way in C# and LINQ to compare a list of elements to each other in the same list.</p>
  
  <p>For example, in pseudo code I would like to do this:</p>
  
  <pre><code>foreach(i in list)    
      foreach(j in list.Except(i))    
          Compare(j,i)
  </code></pre>
  
  <p>I know that Except takes an enumerable instead of single item and may not be the best idea, but it should illustrate my intent.</p>
  
  <p>Any ideas?</p>
  
  <p><strong>Update:</strong>  </p>
  
  <p>I guess this question was a bit to vague.  The goal was to iterate over an list twice (using LINQ) while skipping over the pair <code>(i, i)</code>; whatever <code>Compare(i,j)</code> actually does is irrelevant to my question.</p>
  
  <p>There's two cases then, one where <code>(i,j) == (j,i)</code> and <code>(i,j) != (j,i)</code>.  For the former, George Duckett's skipwhile solution below does the trick, but what about the latter?  This is where my original use of Except came in so that both <code>(i,j)</code> and <code>(j,i)</code> would be evaluated.</p>
  
  <p>So to clarify, is there a better way to skip over an element in a list, other than <code>list.Except(Enumerable.Repeat(i,1))</code>?</p>