Export (0) Print
Expand All

XmlSerializer Constructor (Type, Type[])

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
)

Parameters

type
Type: System.Type
The type of the object that this XmlSerializer can serialize.
extraTypes
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.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft