title: Nullable type and .HasValue still throws a Null Exception
body: <p>I have a class describing the various Phones stored. Sometimes the <code>Importance</code> property can be null. Here is the class</p>
  
  <pre><code>public class PhoneTypeListInfo
  {
      public string AccountNum { get; set; }
      public int PhoneType { get; set; }
      public string PhoneNum { get; set; }
  
      public int Importance { get; set; }
  }
  </code></pre>
  
  <p>I have defined a function that will return a <code>PhoneTypeListInfo</code> if the Phone number and account number match a given set of values.</p>
  
  <pre><code>    protected PhoneTypeListInfo RetrievePhoneType(string info, string acctNumber)
      {
          PhoneTypeListInfo type = xPhoneTypeList.Where(p =&gt; p.PhoneNum == info &amp;&amp; p.AccountNum == acctNumber).FirstOrDefault();
  
          return type;
      }
  </code></pre>
  
  <p>This all works great. The problem I'm having is with the linq query below.</p>
  
  <pre><code>List&lt;AlertBasedPhones&gt; xAccountPhones = new List&lt;AlertBasedPhones&gt;();
  xAccountPhones = (from x in xAccountStuff
                    where x.Media == "Phone"
                    let p = RetrievePhoneType(x.Info, acct.AccountNumber)
                    let xyz = x.Importance = (p.Importance as int?).HasValue ? p.Importance : 0
                    orderby p.Importance descending
                    select x).ToList();
  </code></pre>
  
  <p>What I am doing above is attempting to use a different class that has a different composition, except for obtaining the 'Importance' property from the PhoneTypeListInfo.</p>
  
  <p>My question ultimately is, What do I need to do to allow <code>p.Importance</code> to be null, and set it to 0 if it is null, making <code>x.Importance</code> 0 as well.</p>