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

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 Class0405
Public Class Employee06
Public Name As String07
End Class0809
Public Class Manager10
Inherits Employee11
Public Level As Integer12 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:
    <XmlElement(Type:=GetType(Employee))> _
C. Insert the following code between lines 1 and 2 of the code segment:
    <XmlArray(ElementName:="Employees")> _
D. Insert the following code between lines 5 and 6 of the code segment:
    <XmlElement(Type:=GetType(Employee))>
    andInsert the following code between lines 10 and 11 of the code segment:
    <XmlElement(Type:=GetType(Manager))>


Answer: A 

No comments:

Post a Comment