Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ExtensionDataObject Class
Collapse the table of content
Expand the table of content

ExtensionDataObject Class

Stores data from a versioned data contract that has been extended by adding new members.


Namespace:  System.Runtime.Serialization
Assembly:  System.Runtime.Serialization (in System.Runtime.Serialization.dll)

type ExtensionDataObject =  class end

The ExtensionDataObject type exposes the following members.

Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The ExtensionDataObject is the structure that stores extra data encountered by the XmlObjectSerializer during deserialization operations. The structure is used by serialization to write the extra data into the serialized instance. The structure is returned by the ExtensionData property of the IExtensibleDataObject interface.

The following code serializes an instance of a type (PersonVersion2) that is the second version of the serializable type (Person). The second version contains extra data (ID field) that is not present in the first version. The code then deserializes the XML document into a Person object, then immediately reserializes the object including the extra data. Finally, the code deserializes the new XML into a PersonVersion2 object and writes the complete data to the console, proving that the data has made a round trip to and from an older version of the type. Note that the DataContractAttribute attribute must be applied with the Name and Namespace properties set to the same name and namespace as the original class.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft