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.WriteEndDocument();
B.
binary.WriteEndDocumentAsync();
C.
binary.WriteEndElementAsync();
D.
binary.Flush();
Explanation:
* 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
Not A. binary.WriteEndElement() raises exception.
D.
binary.Flush();
Correct answer: D
The answer is A, not D! Be careful
https://msdn.microsoft.com/tr-tr/library/ms573852(v=vs.110).aspx
İf use at the end binary.Flush(); so where binary.Close(); ?
This is called instead of Close when you want to write more to the underlying stream without losing what is still in the buffer.
Correct answer: D
https://msdn.microsoft.com/en-us/library/ms752244(v=vs.110).aspx
Answer is D
Answer is D
This is called instead of Close when you want to write more to the underlying stream without losing what is still in the buffer.