Question:You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You define the following class:
public class Product {
public decimal Price { get; set; }
}
Your application contains a Web form with a Label control named lblPrice.
You use a StringReader variable named xmlStream to access the following XML fragment:
<Product>
<Price>35</Price>
</Product>
You need to display the price of the product from the XML fragment in the lblPrice Label control.
Which code segment should you use? 

A DataTable dt = new DataTable();
dt.ExtendedProperties.Add("Type", "Product");
dt.ReadXml(xmlStream);
lblPrice.Text = dt.Rows[0]["Price"].ToString(); 

B XmlReader xr = XmlReader.Create(xmlStream);
Product boughtProduct = xr.ReadContentAs(typeof(Product), null) as Product;
lblPrice.Text = boughtProduct.Price.ToString(); 

C XmlSerializer xs = new XmlSerializer(typeof(Product));
Product boughtProduct = xs.Deserialize(xmlStream) as Product;
lblPrice.Text = boughtProduct.Price.ToString(); 

D XmlDocument xDoc = new XmlDocument();
xDoc.Load(xmlStream);
Product boughtProduct = xDoc.OfType<Product>().First();
lblPrice.Text = boughtProduct.Price.ToString(); 

+ Answer
+ Report
Total Preview: 2686

Copyright © 2024. Powered by Intellect Software Ltd