For example this snippet of code:
private void LoadComments(Member member, XElement commentsXml)
{
member.Comments = (from comment in commentsXml.Descendants("comment")
select new Comment()
{
ID = comment.Element("id").Value,
Text = comment.Element("text").Value,
Date = comment.Element("date").Value,
Owner = comment.Element("user").Element("name").Value
}).ToList();
}
ReSharper warns me of a possible NullReferenceException on the comment.Element lines. True enough, the exception fired.
Any suggestion of how to avoid this? What about if it returns null, just return an empty string, is this possible?