Populates a SerializationInfo with the data needed to serialize the target object.
Assembly: mscorlib (in mscorlib.dll)
Any objects that are included in the SerializationInfo are automatically tracked and serialized by the formatter.
It is not guaranteed that this method will be called only once per object instance during serialization. Therefore, the method should be implemented in such a way that its behavior will be the same regardless of the number of times it is called.
The following example uses the method to set alternate values for a serialized object. The code uses the AddValue method of the SerializationInfo class to store the alternate values when the object is serialized. Conversely, when the constructor of the Person class is called during deserialization, the alternatve values are retrieved using the GetValue method and reassigned to the object's fields.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.