Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataContractSerializer.DataContractSerializer(Type, Generic IEnumerable) Constructor

Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type, and a collection of known types that may be present in the object graph.

Namespace: System.Runtime.Serialization
Assembly: System.Runtime.Serialization (in system.runtime.serialization.dll)

public DataContractSerializer (
	Type type,
	IEnumerable<Type> knownTypes
)
public DataContractSerializer (
	Type type, 
	IEnumerable<Type> knownTypes
)
public function DataContractSerializer (
	type : Type, 
	knownTypes : IEnumerable<Type>
)
Not applicable.

Parameters

type

A Type that specifies the type of the instances that will be serialized or deserialized.

knownTypes

An IEnumerable of Type that contains the types that may be present in the object graph.

The following example creates an instance of the DataContractSerializer that specifies the type to serialize or deserialize and a collection of known types that can be used in the object graph.

public static void Constructor2()
{
    // Create a generic List of types and add the known types
    // to the collection.
    List<Type> knownTypeList = new List<Type>();
    knownTypeList.Add(typeof(PurchaseOrder));
    knownTypeList.Add(typeof(PurchaseOrderV3));

    // Create a DatatContractSerializer with the collection.
    DataContractSerializer ser2 = new DataContractSerializer(
        typeof(Orders), knownTypeList);

    // Other code not shown.
}

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

Show:
© 2017 Microsoft