Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IDataContractSurrogate::GetObjectToSerialize Method (Object^, Type^)

 

During serialization, returns an object that substitutes the specified object.

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

Object^ GetObjectToSerialize(
	Object^ obj,
	Type^ targetType
)

Parameters

obj
Type: System::Object^

The object to substitute.

targetType
Type: System::Type^

The Type that the substituted object should be assigned to.

Return Value

Type: System::Object^

The substituted object that will be serialized. The object must be serializable by the DataContractSerializer. For example, it must be marked with the DataContractAttribute attribute or other mechanisms that the serializer recognizes.

This method must not return null because on deserialization the data will be cast to type Object and an InvalidCastException is thrown.

The following example shows an implementation of the GetObjectToSerialize method.

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

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