You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application reads the following contacts.xml file.
<contacts>
<contact contactId="2">
<firstName>Don</firstName>
<lastName>Hall</lastName>
</contact>
<contact contactId="3">
<firstName>Simon</firstName>
<lastName>Rapier</lastName>
</contact>
<contact contactId="4">
<firstName>Shu</firstName>
<lastName>Ito</lastName>
</contact>
</contacts>
You write the following code segment. (Line numbers are included for reference only.)
01 XDocument loaded = XDocument.Load(@"C:contacts.xml");
02
03 foreach (string name in q)
04 Console.WriteLine("{0}", name);
You need to ensure that the application outputs only the names Simon Rapier and Shu Ito.
Which code segment should you insert at line 02?
A.
var q = from c in loaded.Descendants("contact").Skip(1)
select (string)c.Element("firstName") + " " +
(string)c.Element("lastName");
B.
var q = from c in loaded.Descendants("contact").Skip(0)
select (string)c.Element("firstName") + " " +
(string)c.Element("lastName");
C.
var q = from c in loaded.Descendants("contact")
where c.IsAfter(c.FirstNode)
select (string)c.Element("firstName") + " " +
(string)c.Element("lastName");
D.
var q = from c in loaded.Descendants("contact")
where (int)c.Attribute("contactId") < 4
select (string)c.Element("firstName") + " " +
(string)c.Element("lastName");