exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 2 question 147 discussion

Actual exam question from Microsoft's 70-483
Question #: 147
Topic #: 2
[All 70-483 Questions]

You are troubleshooting an application that uses a class named FullName. The class is decorated with the DataContractAttribute attribute. The application includes the following code. Line numbers are included for reference only.

You need to ensure that the entire FullName object is serialized to the memory stream object.
Which code segment should you insert at line 09?

  • A. binary.WriteEndElement();
  • B. binary.WriteEndDocument();
  • C. binary.WriteEndElementAsync();
  • D. binary.Flush();
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️
✑ DataContractSerializer.WriteEndObject Method (XmlDictionaryWriter)
Writes the closing XML element using an XmlDictionaryWriter.
✑ Note on line 07: DataContractSerializer.WriteObject Method
Writes all the object data (starting XML element, content, and closing element) to an XML document or stream.
XmlDictionaryWriter

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
Bio
Highly Voted 5 years, 10 months ago
D: https://docs.microsoft.com/en-us/dotnet/framework/wcf/samples/datacontractserializer-sample
upvoted 28 times
...
sscooter1010
Highly Voted 5 years, 3 months ago
// code static MemoryStream WriteName(Name name) { var ms = new MemoryStream(); var binary = XmlDictionaryWriter.CreateBinaryWriter(ms); var ser = new DataContractSerializer(typeof(Name)); ser.WriteObject(binary, name); binary.WriteEndDocument(); Console.WriteLine("After binary.WritenEndDocument: Binary stream is {0} bytes long", ms.Length); binary.Flush(); Console.WriteLine("After binary.Flush(), Binary stream is {0} bytes long", ms.Length); return ms; } // output // After binary.WritenEndDocument: Binary stream is 0 bytes long // After binary.Flush(), Binary stream is 131 bytes long
upvoted 7 times
...
nichlas
Most Recent 4 years, 4 months ago
This really confuses me.. Everytime this question shows up the "correct answer" is "WriteEndDocument" but all the users in the discussion says it must be "flush"
upvoted 2 times
...
noussa
4 years, 4 months ago
D is the correct answer
upvoted 3 times
...
xman
5 years, 2 months ago
Answer: B Explanation Example: MemoryStream stream2 = new MemoryStream(); XmlDictionaryWriter binaryDictionaryWriter = XmlDictionaryWriter.CreateBinaryWriter(stream2); serializer.WriteObject(binaryDictionaryWriter, record1); binaryDictionaryWriter.Flush(); Incorrect: Not A: throws InvalidOperationException. Reference: https://msdn.microsoft.com/en-us/library/ms752244(v=vs.110).aspx
upvoted 2 times
xman
5 years, 2 months ago
Sorry D not B
upvoted 9 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 ...