NetDataContractSerializer Constructor (XmlDictionaryString, XmlDictionaryString)

NetDataContractSerializer Constructor (XmlDictionaryString, XmlDictionaryString)

 

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 Sub New (
	rootName As XmlDictionaryString,
	rootNamespace As XmlDictionaryString
)

Parameters

rootName
Type: System.Xml.XmlDictionaryString

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

rootNamespace
Type: System.Xml.XmlDictionaryString

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 Shared Sub Constructor4() 
    ' Create an XmlDictionary and add values to it.
    Dim d As New XmlDictionary()
    Dim name_value As XmlDictionaryString =d.Add("Customer")
    Dim ns_value As XmlDictionaryString = d.Add("http://www.contoso.com")

    ' Create the serializer.
    Dim ser As New System.Runtime.Serialization. _
       NetDataContractSerializer(name_value, ns_value)

    ' Other code not shown.

End Sub 

.NET Framework
Available since 3.0
Return to top
Show:
© 2016 Microsoft