DataContractSerializer Constructor (Type, String, String)

DataContractSerializer.DataContractSerializer(Type, String, String) Constructor

Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type using the supplied XML root element and namespace.

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

public DataContractSerializer (
	Type type,
	string rootName,
	string rootNamespace
public DataContractSerializer (
	Type type, 
	String rootName, 
	String rootNamespace
public function DataContractSerializer (
	type : Type, 
	rootName : String, 
	rootNamespace : String
Not applicable.



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


The name of the XML element enclosing the content to serialize or deserialize.


The namespace of the XML element enclosing the content to serialize or deserialize.

The following example creates an instance of the DataContractSerializer that specifies the type to serialize or deserialize as well as the XML name and namespace to read from or write to the XML document.

public static void Constructor3()
    // Create an instance of the DataContractSerializer
    // specifying the type, and name and 
    // namespace as strings.
    DataContractSerializer ser =
        new DataContractSerializer(

    // 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

© 2015 Microsoft