I'm working in deserialization and right now I am able to successfully deserialize XML as intended.
However, when I try to deserialize an XML-tag that dosen't exist, I get the NullException error and that is understandable.
I want it to just return null if the tag doesnt exist instead of getting error message but I'm not sure how to do that.
ist<FolkbokforingspostTYPE> deserializedList = new List<FolkbokforingspostTYPE>(); deserializedList = Deserialize<List<FolkbokforingspostTYPE>>(); var PostNr = deserializedList.Select(item => item.Personpost.Adresser.Folkbokforingsadress.PostNr).ToList(); In this case, the tag Folkbokforingsadress doesn't always exist. Instead of getting the error, I just want it to return NULL and move on, how can I do that?
No comments:
Post a Comment