XmlSerializer.Deserialize Method (TextReader)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Deserializes the XML document contained by the specified TextReader.

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

Syntax

Public Function Deserialize ( _
    textReader As TextReader _
) As Object
public Object Deserialize(
    TextReader textReader
)

Parameters

Return Value

Type: System..::.Object
The Object being deserialized.

Exceptions

Exception Condition
InvalidOperationException

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

Remarks

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.

Note

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.

Note

The XmlSerializer cannot deserialize arrays of List<(Of <(T>)>).

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

XmlSerializer Class

Deserialize Overload

System.Xml.Serialization Namespace

CanDeserialize

Serialize