Linq check if if element exist if it does return value else an empty string

Viewed 11

I've broken down a longer linq query upon the point where it sometimes crashes. The crash is that Returnattribute is not always found. How to improve the query below so that it will check that it exist and if so get the value or else an empty string (without hanging).

var result = t.Select(x => x.Element(Returnattribute).Value).FirstOrDefault();
0 Answers
Related