nerdexam
Microsoft

98-372 · Question #84

Which class can be used to write an object to a string, to write strings to a file, or to serialize XML?

The correct answer is C. TextWriter class. The TextWriter class is used to provide a writer that can write a sequential chain of characters. It is the abstract base class of the StreamWriter and StringWriter classes. It can be used to write an object to a string, write strings to a file, or to serialize XML. It can also…

Understanding Namespaces and Classes

Question

Which class can be used to write an object to a string, to write strings to a file, or to serialize XML?

Options

  • AOutputWriter class
  • BStringWriter class
  • CTextWriter class
  • DStreamWriter class

How the community answered

(16 responses)
  • A
    6% (1)
  • B
    13% (2)
  • C
    75% (12)
  • D
    6% (1)

Explanation

The TextWriter class is used to provide a writer that can write a sequential chain of characters. It is the abstract base class of the StreamWriter and StringWriter classes. It can be used to write an object to a string, write strings to a file, or to serialize XML. It can also be used to write text to a custom backing store using the same APIs. By default, it is not thread safe. A derived class must at least implement the Write method to make a functional instance of the TextWriter. Answer: D is incorrect. The StreamWriter class is used to implement a TextWriter for writing characters to a stream in a specific encoding. Answer: B is incorrect. The StringWriter class is used to implement a TextWriter for writing information to a string. Answer: A is incorrect. There is no such class as OutputWriter in the System.IO namespace.

Topics

#TextWriter#StringWriter#StreamWriter#IO classes

Community Discussion

No community discussion yet for this question.

Full 98-372 Practice