exam questions

Exam 70-486 All Questions

View all questions & answers for the 70-486 exam

Exam 70-486 topic 3 question 1 discussion

Actual exam question from Microsoft's 70-486
Question #: 1
Topic #: 3
[All 70-486 Questions]

You are designing a Windows Communication Foundation (WCF) service that uses the Product class.
You need to update the class to meet the storage requirement.
What should you do? (Each correct answer presents part of the solution. Choose all that apply.)

  • A. Mark the Product class with the DataContract attribute.
  • B. Mark the public members of the Product class with the DataContractFormat attribute.
  • C. Mark the Product class with the CollectionDataContract attribute.
  • D. Mark the public members of the Product class with the DataMember attribute.
Show Suggested Answer Hide Answer
Suggested Answer: AD 🗳️
As of .NET 3.5 SP1, you don't haveto add data contract or data member attributes anymore - if you don't then the data contract serializer will serialize all public properties on your class, just like the XML serializer would.
HOWEVER: by not adding those attributes, you lose a lot of useful capabilities:
✑ without [DataContract], you cannot define an XML namespace for your data to live in
✑ without [DataMember], you cannot serialize non-public properties or fields
✑ without [DataMember], you cannot define an order of serialization (Order=) andthe DCS will serialize all properties alphabetically
✑ without [DataMember], you cannot define a different name for your property (Name=)
✑ without [DataMember], you cannot define things like IsRequired= or other useful attributes
✑ without [DataMember], you cannot leave out certain public properties - all public properties will be serialized by the DCS
References:
http://stackoverflow.com/questions/4836683/when-to-use-datacontract-and-datamember-attributes

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Lt_munchies
4 years, 9 months ago
A and D
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...