Question:You create a class library that contains the class hierarchy defined in the following code segment. (Line numbers are included for reference only.)
01. public ref class Employee {
02.
03. public :
04. String= Name;
05. };
06.
07. public ref class Manager : public Employee {
08.
09. public :
10. int Level;
11. };
12.
13. public ref class Group {
14.
15. public :
16. array<Employee=>= Employees;
17. };
You create an instance of the Group class. You populate the fields of the instance. When you attempt to serialize the instance by using the Serialize method of the XmlSerializer class, you receive InvalidOperationException. You also receive the following error message: "There was an error generating the XML document."
You need to modify the code segment so that you can successfully serialize instances of the Group class by using the XmlSerializer class. You also need to ensure that the XML output contains an element for all public fields in the class hierarchy.
What should you do?
 

A Insert the following code between lines 14 and 15 of the code segment: [XmlArray(ElementName="Employees")] 

B Insert the following code between lines 3 and 4 of the code segment:
[XmlElement(Type = __typeof(Employee))]
and
Insert the following code segment between lines 8 and 9 of the code segment:
[XmlElement(Type = __typeof(Manager))] 

C Insert the following code between lines 14 and 15 of the code segment:
[XmlArrayItem(Type = __typeof(Employee))]
[XmlArrayItem(Type = __typeof(Manager))] 

D Insert the following code between lines 14 and 15 of the code segment:
[XmlElement(Type = __typeof(Employees))] 

+ Answer
+ Report
Total Preview: 1154

Copyright © 2024. Powered by Intellect Software Ltd