Export (0) Print
Expand All

XmlSerializer.Deserialize Method (TextReader)

Deserializes the XML document contained by the specified TextReader.

Namespace:  System.Xml.Serialization
Assembly:  System.Xml.Serialization (in System.Xml.Serialization.dll)

public Object Deserialize(
	TextReader textReader
)

Parameters

textReader
Type: System.IO.TextReader
The TextReader that contains the XML document to deserialize.

Return Value

Type: System.Object
The Object being deserialized.

ExceptionCondition
InvalidOperationException

An error occurred during deserialization. The original exception is available using the InnerException property.

Deserialization is the process of reading an instance of an XML document and constructing an object that is strongly typed to the XML Schema (XSD) of the document.

Before deserializing, an XmlSerializer must be constructed using the type of the object that is being deserialized.

Classes that inherit from TextReader include StringReader and StreamReader. If you are using a StreamReader to deserialize an object, you must construct the StreamReader with an appropriate Encoding. The encoding specified by the XML document is ignored.

NoteNote:

To use the encoding specified by the XML document, use the Deserialize overload that takes an XmlReader instead. The XmlReader automatically detects and uses the encoding specified by the XML document.

NoteNote:

The XmlSerializer cannot deserialize arrays of ArrayList and arrays of List<T>.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft