FormatterServices::GetObjectData Method (Object^, array<MemberInfo^>^)
Extracts the data from the specified object and returns it as an array of objects.
Assembly: mscorlib (in mscorlib.dll)
public: [SecurityCriticalAttribute] static array<Object^>^ GetObjectData( Object^ obj, array<MemberInfo^>^ members )
Parameters
- obj
-
Type:
System::Object^
The object to write to the formatter.
- members
-
Type:
array<System.Reflection::MemberInfo^>^
The members to extract from the object.
Return Value
Type: array<System::Object^>^An array of Object that contains data stored in members and associated with obj.
| Exception | Condition |
|---|---|
| ArgumentNullException | The obj or members parameter is null. An element of members is null. |
| SerializationException | An element of members does not represent a field. |
For each supplied member of the members array the GetObjectData method extracts the value associated with the obj object, and returns it. The length of the returned array is the same as the length of the members array.
The following example creates an instance of a Book class and sets field values on the instance. The code then gets the type information using the GetSerializableMembers method. The code copies the instance data into an object array using the GetObjectData method. A new uninitialized instance of the class is created using the GetSafeUninitializedObject method. Finally, the data from the first instance is copied into the second instance using the PopulateObjectMembers method.
For providing serialization services. Associated enumeration: SecurityPermissionFlag::SerializationFormatter, SecurityAction::LinkDemand.
Available since 1.1