title: How to check null reference in lambda expression in .net
body: <p>i am processing xml file by using following code,but how to check null reference exception which i used to get </p>
  
  <pre><code>var main = System.Xml.Linq.XDocument.Load("1.xml");
  
  string localcellid = main.Descendants()
      .FirstOrDefault(x =&gt; x.Attributes().Any(a =&gt; a.Value == "eNodeBCell_eNodeB"))
      .Descendants("parameter")
      .FirstOrDefault(x =&gt; x.Attributes().Any(a =&gt; a.Value == "LocalCellId"))
      .Attribute("value").Value;
  
  string eNodeBId = main.Descendants()
      .FirstOrDefault(x =&gt; x.Attributes().Any(a =&gt; a.Value == "eNodeB_eNodeB"))
      .Descendants("parameter")
      .FirstOrDefault(x =&gt; x.Attributes().Any(a =&gt; a.Value == "eNodeBId"))
      .Attribute("value").Value;
  </code></pre>