IFormatter.Serialize(Stream, Object) IFormatter.Serialize(Stream, Object) IFormatter.Serialize(Stream, Object) IFormatter.Serialize(Stream, Object) Method

定義

使用所提供資料流的指定根序列化物件或物件 Graph。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);
public void Serialize (System.IO.Stream serializationStream, object graph);
abstract member Serialize : System.IO.Stream * obj -> unit
Public Sub Serialize (serializationStream As Stream, graph As Object)

參數

serializationStream
Stream Stream Stream 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 Object Object Object

要序列化的物件或物件 Graph 的根。The object, or root of the object graph, to serialize. 這個根物件的所有子物件會自動地序列化。All child objects of this root object are automatically serialized.

備註

Serialize方法會自動將提供的物件及其所有連接的物件序列化至提供的資料流程。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.

適用於

另請參閱