XmlSerializer.Serialize Method (Stream, Object, XmlSerializerNamespaces)
Assembly: System.Xml (in System.Xml.dll)
member Serialize : stream:Stream * o:Object * namespaces:XmlSerializerNamespaces -> unit
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. To serialize all fields and properties, both public and private, use the BinaryFormatter.
The following example serializes an object with a Stream object. The example also creates an XmlSerializerNamespaces and adds two namespaces to the object. The class that defines the serialized object is also attributed with XmlElementAttribute attributes to specify the namespace for each element.
Available since 8
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1