System.Xml.Serialization.XmlSerializer.Serialize Method

Serializes the specified object and writes the XML document to a file using the specified System.IO.TextWriter and references the specified namespaces.

Syntax

public void Serialize (System.IO.TextWriter textWriter, object o, XmlSerializerNamespaces namespaces)

Parameters

textWriter
The System.IO.TextWriter used to write the XML document.
o
The object to serialize.
namespaces
The System.Xml.Serialization.XmlSerializerNamespaces that contains namespaces for the generated XML document.

Remarks

When the XmlSerializer.Serialize(System.IO.TextWriter, object) method is invoked the public fields and read/write properties of an object are converted into XML. Methods, indexers, private fields, and read-only properties are not serialized. To serialize all fields and properties, both public and private, use the System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.

Use the textWriter parameter to specify an object that derives from the abstract System.IO.TextWriter class. Classes that derive from System.IO.TextWriter class include:

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