I have a big hierarchical object and I want one propertie from this structure. The problem is, every level of that object could be null. (It's data from a structured XML)
I want something like this:
_data = record.RltdPties.DbtrAcct.Id.Item
if one of this sub object is null, the data should be also null. Is there a better way the validate my object instead of this:
if(record!=null && record.RltdPties != null && record.RltdPties.DbtrAcct != null && record.RltdPties.DbtrAcct.Id != null)
{
_data = record.RltdPties.DbtrAcct.Id.Item
}
I could make a try{} catch{} block, but that's not a good solution.