Export (0) Print
Expand All

NetDataContractSerializer.NetDataContractSerializer(XmlDictionaryString, XmlDictionaryString) Constructor

Initializes a new instance of the NetDataContractSerializer class with two parameters of type XmlDictionaryString that contain the root element and namespace used to specify the content.

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

public NetDataContractSerializer (
	XmlDictionaryString rootName,
	XmlDictionaryString rootNamespace
)
public NetDataContractSerializer (
	XmlDictionaryString rootName, 
	XmlDictionaryString rootNamespace
)
public function NetDataContractSerializer (
	rootName : XmlDictionaryString, 
	rootNamespace : XmlDictionaryString
)
Not applicable.

Parameters

rootName

An XmlDictionaryString that contains the name of the XML element that encloses the content to serialize or deserialize.

rootNamespace

An XmlDictionaryString that contains the namespace of the XML element that encloses the content to serialize or deserialize.

The XmlDictionaryString can be used to optimize performance when the same set of strings is used across object instances.

The following example creates an instance of the DataContractSerializer specifying the XML root element and namespace (as XmlDictionaryString arguments) it will expect when deserializing an object.

public static void Constructor4()
{
    // Create an XmlDictionary and add values to it.
    XmlDictionary d = new XmlDictionary();
    // Initialize the out variables.
    XmlDictionaryString name_value = d.Add("Customer");
    XmlDictionaryString ns_value = d.Add("http://www.contoso.com");

    // Create the serializer.
    NetDataContractSerializer ser =
        new NetDataContractSerializer(
        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