title: How can I make sure that FirstOrDefault<KeyValuePair> has returned a value
body: <p>Here's a simplified version of what I'm trying to do:</p>
  
  <pre><code>var days = new Dictionary&lt;int, string&gt;();
  days.Add(1, "Monday");
  days.Add(2, "Tuesday");
  ...
  days.Add(7, "Sunday");
  
  var sampleText = "My favorite day of the week is 'xyz'";
  var day = days.FirstOrDefault(x =&gt; sampleText.Contains(x.Value));
  </code></pre>
  
  <p>Since 'xyz' is not present in the dictionary, the FirstOrDefault method will not return a valid value. I want to be able to check for this situation but I realize that I can't compare the result to "null" because KeyValuePair is a struc. The following code is invalid:</p>
  
  <pre><code>if (day == null) {
      System.Diagnotics.Debug.Write("Couldn't find day of week");
  }
  </code></pre>
  
  <p>We you attempt to compile the code, Visual Studio throws the following error: </p>
  
  <pre><code>Operator '==' cannot be applied to operands of type 'System.Collections.Generic.KeyValuePair&lt;int,string&gt;' and '&lt;null&gt;'
  </code></pre>
  
  <p>How can I check that FirstOrDefault has returned a valid value?</p>