XmlSerializer Constructor (Type, Type[])

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Initializes a new instance of the XmlSerializer class that can serialize objects of the specified type into XML documents and deserialize XML documents into objects of a specified type. If a property or field returns an array, the extraTypes parameter specifies objects that can be inserted into the array.

Namespace:  System.Xml.Serialization
Assembly:  System.Xml.Serialization (in System.Xml.Serialization.dll)

public XmlSerializer(
	Type type,
	Type[] extraTypes


Type: System.Type
The type of the object that this XmlSerializer can serialize.
Type: System.Type []
A Type array of additional object types to serialize.

By default, if a public property or field returns an object or array of objects, the object types are automatically serialized. However, if a class contains a field or property that returns an array of type Object, any object can be inserted into that array. In that case, the XmlSerializer must be instructed to expect all the possible object types that are inserted into the Object array. To do this, use the extraTypes parameter to specify the extra object types to serialize or deserialize.

You can also use the extraTypes parameter to specify types derived from a base class. For example, suppose a base class named Phone exists and a class named InternationalPhone derives from it. Use the extraTypes parameter to specify the derived type as well.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2015 Microsoft