Edit

Share via


IFormatter.Serialize(Stream, Object) Method

Definition

Caution

BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.

Serializes an object, or graph of objects with the given root to the provided stream.

public:
 void Serialize(System::IO::Stream ^ serializationStream, System::Object ^ graph);
[System.Obsolete("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId="SYSLIB0011", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public void Serialize (System.IO.Stream serializationStream, object graph);
public void Serialize (System.IO.Stream serializationStream, object graph);
[<System.Obsolete("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId="SYSLIB0011", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
abstract member Serialize : System.IO.Stream * obj -> unit
abstract member Serialize : System.IO.Stream * obj -> unit
Public Sub Serialize (serializationStream As Stream, graph As Object)

Parameters

serializationStream
Stream

The stream where the formatter puts the serialized data. This stream can reference a variety of backing stores (such as files, network, memory, and so on).

graph
Object

The object, or root of the object graph, to serialize. All child objects of this root object are automatically serialized.

Attributes

Remarks

The Serialize method automatically serializes the provided objects, and all objects connected to it, to the provided stream.

By default, the serialization process records an object's state by gathering the values of all its fields (public and private). These fields are saved to the stream along with information about the object such as the name qualified by the assembly for its type.

Applies to

See also