XmlSerializer.Serialize Method (TextWriter, Object)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Serializes the specified Object and writes the XML document to a file using the specified TextWriter.
Assembly: System.Xml.Serialization (in System.Xml.Serialization.dll)
Parameters
- textWriter
- Type: System.IO.TextWriter
The TextWriter used to write the XML document.
- o
- Type: System.Object
The Object to serialize.
The Serialize method converts the public fields and read/write properties of an object into XML. It does not convert methods, indexers, private fields, or read-only properties.
In the textWriter parameter, specify an object that derives from the abstract TextWriter class. Classes that derive from TextWriter include:
Note: |
|---|
The XmlSerializer cannot serialize arrays of List(Of T). |
Version Notes
Windows Phone
The XmlSerializer.Serialize method throws an InvalidOperationException if the XmlSerializer object is initialized with a type parameter that contains an array of objects of type XElement.
Note: