Export (0) Print
Expand All

DataContractSerializer.DataContractSerializer(Type, XmlDictionaryString, XmlDictionaryString) Constructor

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

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

public DataContractSerializer (
	Type type,
	XmlDictionaryString rootName,
	XmlDictionaryString rootNamespace
)
public DataContractSerializer (
	Type type, 
	XmlDictionaryString rootName, 
	XmlDictionaryString rootNamespace
)
public function DataContractSerializer (
	type : Type, 
	rootName : XmlDictionaryString, 
	rootNamespace : XmlDictionaryString
)
Not applicable.

Parameters

type

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

rootName

An XmlDictionaryString that contains the root element name of the content.

rootNamespace

An XmlDictionaryString that contains the namespace of the root element.

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 (as XmlDictionaryString objects) to read from or write to the XML document.

public static void Constructor4()
{
    // Create an instance of the DataContractSerializer
    // specifying the type, and name and 
    // namespace as XmlDictionaryString objects.

    // Create an XmlDictionary and add values to it.
    XmlDictionary d = new XmlDictionary();
    XmlDictionaryString name_value = d.Add("Customer");
    XmlDictionaryString ns_value = d.Add("http://www.contoso.com");

    // Create the serializer.
    DataContractSerializer ser =
        new DataContractSerializer(
        typeof(Person),
        name_value,
        ns_value);
    // 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

ADD
Show:
© 2014 Microsoft