IFormatter.Serialize(Stream, Object) 方法

定義

警告

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

使用所提供資料流的指定根序列化物件或物件 Graph。

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)

參數

serializationStream
Stream

格式子置放已序列化資料的所在資料流。 這個資料流可以參考多種支援存放區 (例如檔案、網路、記憶體等等)。

graph
Object

要序列化的物件或物件 Graph 的根。 這個根物件的所有子物件都會自動序列化。

屬性

備註

方法 Serialize 會自動將提供的物件及其所連接的所有物件序列化至提供的資料流程。

根據預設,序列化程式會收集其所有欄位的值, (公用和私用) 來記錄物件的狀態。 這些欄位會儲存至資料流程,以及物件的相關資訊,例如元件為其類型限定的名稱。

適用於

另請參閱