Why can’t I call FirstOrDefault() on this XML, whereas I have other XDocuments where FirstOrDefault() is available?
var actual = new XDocument(
new XComment("This is a comment"),
new XElement("Root",
new XElement("Child1", "data1"),
new XElement("Child2", "data2")
));
actual.Descendants("Child1"). <- FirstOrDefault does not show up.
You should include
System.Linqnamespace in the top of your cs file.If you’re using ReSharper, try push
ctrl+alt+spaceafter typing.and look forFirstOrDefault. R# helps to manage namespaces.