I have the following code:
var te = doc.Descendants("TESTID").Where(x=> (string)x.Attribute("TESTIDNumber")= finalstr).FirstOrDefault();
In the case te is null
, then the following gives an exeption:
var ignorete = doc.Descendants("IgnoreTESTID").Where(x=> (string)x.Attribute("TESTIDNumber")== te.FirstAttribute.Value.toString();
The exception is : Object not set to an instance of the Object
How do I make ignorete
to null if te
goes null ?