PrepAway - Latest Free Exam Questions & Answers

How should you complete the relevant code?

DRAG DROP
An application serializes and deserializes XML from streams. The XML streams are in the following
format:

The application reads the XML streams by using a DataContractSerializer object that is declared by
the following code segment:
var ser = new DataContractSerializer(typeof(Name));
You need to ensure that the application preserves the element ordering as provided in the XML
stream.
How should you complete the relevant code? (To answer, drag the appropriate attributes to the
correct locations in the answer area-Each attribute may be used once, more than once, or not at all.
You may need to drag the split bar between panes or scroll to view content.)

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:
DataContractAttribute – Specifies that the type defines or implements a data contract and is
serializable by a serializer, such as the DataContractSerializer. To make their type serializable, type
authors must define a data contract for their type.
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractattribute.aspx
DataMemberAttribute – When applied to the member of a type, specifies that the member is part of
a data contract and is serializable by the DataContractSerializer.
http://msdn.microsoft.com/en-us/library/ms574795.aspx

8 Comments on “How should you complete the relevant code?

      1. Sjoerd says:

        No, it’s 1,2,3
        The basic rules for data ordering include:
        •If a data contract type is a part of an inheritance hierarchy, data members of its base types are always first in the order.
        •Next in order are the current type’s data members that do not have the Order property of the DataMemberAttribute attribute set, in alphabetical order.
        •Next are any data members that have the Order property of the DataMemberAttribute attribute set. These are ordered by the value of the Order property first and then alphabetically if there is more than one member of a certain Order value. Order values may be skipped.




        2



        0
      1. phikret says:

        If you are confused with the order=10, note that value of order in this example is not important. Follow the strict rules for sorting serialized fields when DataContract/DataMember is used:

        •If a data contract type is a part of an inheritance hierarchy, data members of its base types are always first in the order.
        •Next in order are the current type’s data members that do not have the Order property of the DataMemberAttribute attribute set, in alphabetical order.
        •Next are any data members that have the Order property of the DataMemberAttribute attribute set. These are ordered by the value of the Order property first and then alphabetically if there is more than one member of a certain Order value. Order values may be skipped.

        Since LastName field does not have any order applied, then whatever order you put on FirstName it will be after LastName.

        So the correct answer is 1,2,3




        0



        0

Leave a Reply