System.Xml.Serialization.XmlSerializer.Serialize Method

Serializes the specified object and writes the XML document to a file using the specified System.Xml.XmlWriter.

Syntax

public void Serialize (System.Xml.XmlWriter xmlWriter, object o)

Parameters

xmlWriter
The System.xml.XmlWriter used to write the XML document.
o
The object to serialize.

Remarks

The XmlSerializer.Serialize(System.IO.TextWriter, object) 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. To serialize all an object's fields and properties, both public and private, use the System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.

In the xmlWriter parameter, specify an object that derives from the abstract System.Xml.XmlWriter class. The System.Xml.XmlTextWriter derives from the System.Xml.XmlWriter.

Note:

The System.Xml.Serialization.XmlSerializer cannot serialize the following: arrays of ArrayList and arrays of List`1.

Requirements

Namespace: System.Xml.Serialization
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0