一款简单易用的基础网络通讯组件库。

FastBinaryFormatterSerializeT(ByteBlock, T, FastSerializerContext) 方法

将对象序列化到字节块中。

Definition

命名空间: TouchSocket.Core
程序集: TouchSocket.Core (在 TouchSocket.Core.dll 中) 版本:4.0.0-beta.143+5fcca7a4e70968794985dc3793adc50531308be6
C#
public static void Serialize<T>(
	ByteBlock byteBlock,
	 in T graph,
	FastSerializerContext serializerContext = null
)

参数

byteBlock  ByteBlock
目标ByteBlock
graph  T
要序列化的对象实例。
serializerContext  FastSerializerContext  (Optional)
序列化上下文,为 时使用默认上下文。

类型参数

T
要序列化的对象类型。

备注

此方法会在序列化数据前写入魔数(协议头),用于反序列化时的校验。

参见