title: Interview Question: .Any() vs if (.Length > 0) for testing if a collection has elements
body: <p>In a recent interview I was asked what the difference between <code>.Any()</code> and <code>.Length &gt; 0</code> was and why I would use either when testing to see if a collection had elements.</p>
  
  <p>This threw me a little as it seems a little obvious but feel I may be missing something.</p>
  
  <p>I suggested that you use <code>.Length</code> when you simply need to know that a collection has elements and <code>.Any()</code> when you wish to filter the results.</p>
  
  <p>Presumably <code>.Any()</code> takes a performance hit too as it has to do a loop / query internally.</p>