XML如何检查节点是否返回null?

l--*_*''' 4 c# xml

我在c#中有这段代码

doc.SelectSingleNode("WhoisRecord/registrant/email").InnerText
Run Code Online (Sandbox Code Playgroud)

我怎样才能检查它是否返回null?

小智 7

var n = doc.SelectSingleNode("WhoisRecord/registrant/email");
if (n != null) { // here is the check
  DoSomething(n.InnerText);
}
Run Code Online (Sandbox Code Playgroud)