Which code segment should you insert at line 09?

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?

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



Leave a Reply 4

Your email address will not be published. Required fields are marked *


Xabi

Xabi

A returns an empty memory stream, D should be correct because after flush the memory stream will contain the written data.

V4andStillWrong

V4andStillWrong

Flush()
When overridden in a derived class, flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.(Inherited from XmlWriter.)