I try this statement to check if SSN is not empty return the value in SSNstr otherwise return null. But this is returning me error Object reference not set to an instance of an object.
when SSN is empty.
Model.DocumentData dt = new Model.DocumentData();
dt.SSNstr = (dt.SSNstr == null ? null :(string)individual.XPathSelectElement("Individual/SSN")).Insert(5,"-").Insert(3,"-");
this is dt class:
[DataMember]
public string SSNstr = string.Empty;
Please attention here I know how to check null value but I like to do it in same line of code. As I have so many fields like this that I need to check I prefer to check in 1 line of the code or change something in dt class that take care of it.