title: Determine sequence contains no element using LINQ
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/341264/linq-max-or-default">LINQ: Max or Default?</a>  </p>
  </blockquote>
  
  
  
  <p>I have some LINQ to filter <code>DateTime</code> vars.</p>
  
  <pre><code>List&lt;DateTime&gt; lst1 = new List&lt;DateTime&gt;();
  
   //.... add DataTime here
  
  var d = lst1.Where(q =&gt; q &lt;= DateTime.Now).Max();
  </code></pre>
  
  <p><strong>And if I have no matched item the exceptions occurs.</strong></p>
  
  <p>I need to get empty <code>d</code> or at least <code>null</code> and I don't need exception here at all.</p>
  
  <p>How do I can fix it?</p>
  
  <p>Thank you!</p>