IFormatter.Serialize(Stream, Object) 方法

定义

注意

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

将对象或具有给定根的对象图形序列化为所提供的流。

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

要序列化的对象或对象图形的根。 将自动序列化此根对象的所有子对象。

属性

注解

方法 Serialize 自动将所提供的对象以及连接到该对象的所有对象序列化到提供的流。

默认情况下,序列化过程通过收集其所有字段的值 (公共和专用) 来记录对象的状态。 这些字段与有关对象的信息(例如程序集为其类型限定的名称)一起保存到流中。

适用于

另请参阅