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 Class Group
02 Public Employees As Employee()
03 End Class 05 Public Class Employee
06 Public Name As String
07 End Class 09 Public Class Manager
10 Inherits Employee
11 Public Level As Integer
12 End Class
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 1 and 2 of the code segment:
<XmlArrayItem(Type:=GetType(Employee))> _ <XmlArrayItem(Type:=GetType(Manager))> _
B Insert the following code between lines 1 and 2 of the code segment:
<XmlArray(ElementName:="Employees")> _
C Insert the following code between lines 5 and 6 of the code segment:
<XmlElement(Type:=GetType(Employee))>
and
Insert the following code between lines 10 and 11 of the code segment:
<XmlElement(Type:=GetType(Manager))>
D Insert the following code between lines 1 and 2 of the code segment:
<XmlElement(Type:=GetType(Employee))> _