EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.
Ce sujet n'a pas encore été évalué - Évaluez ce sujet

XmlSerializer.Serialize Method (TextWriter, Object, XmlSerializerNamespaces)

April 12, 2014

Serializes the specified Object and writes the XML document to a file using the specified TextWriter and references the specified namespaces.

Namespace:  System.Xml.Serialization
Assembly:  System.Xml.Serialization (in System.Xml.Serialization.dll)
public void Serialize(
	TextWriter textWriter,
	Object o,
	XmlSerializerNamespaces namespaces
)

Parameters

textWriter
Type: System.IO.TextWriter
The TextWriter used to write the XML document.
o
Type: System.Object
The Object to serialize.
namespaces
Type: System.Xml.Serialization.XmlSerializerNamespaces
The XmlSerializerNamespaces that contains namespaces for the generated XML document.
ExceptionCondition
InvalidOperationException

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

When the Serialize 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.

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

NoteNote:

The XmlSerializer cannot serialize arrays of List<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.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Cela vous a-t-il été utile ?
(1500 caractères restants)
Merci pour vos suggestions.
Afficher:
© 2014 Microsoft. Tous droits réservés.