我是对象序列化的新手,在学习如何使用 BinaryFormatter 读写文件(反序列化和序列化)的过程中,我遇到了 BinaryReader 和 BinaryWriter ,它们似乎在做同样的事情.
I'm new to object serialization, and in the course of my learning how to read from and write to a file (deserialize and serialize) using BinaryFormatter, I came across BinaryReader and BinaryWriter, which seemed to be doing the same thing.
BinaryFormatter.Serialize()和 BinaryWriter 之间是否存在细微差别?还是 BinaryWriter 只是一种更紧凑的方式来执行与 BinaryFormatter.Serialize()相同的动作?
Is there some subtle difference between BinaryFormatter.Serialize() and BinaryWriter? Or is BinaryWriter just a more compact way performing the the same action as BinaryFormatter.Serialize()?
推荐答案BinaryWriter 用于将二进制类型的原始类型写入流,并支持以特定编码写入字符串. BinaryFromatter 负责将整个对象或连接的对象图序列化为二进制格式.因此,我想您可以说 BinaryWriter 是一种更基本的形式,例如 BinaryFormatter .
BinaryWriter is used to write primitive types in binary to a stream and supports writing strings in a specific encoding. BinaryFromatter is responsible for serializing an entire object or graph of connected objects into binary format. So, I suppose you can say BinaryWriter is a much more elementary form of something like BinaryFormatter.
我在这里获得此信息: BinaryWriter & BinaryFormatter
I got this information here: BinaryWriter & BinaryFormatter
更多推荐
BinaryWriter和BinaryFormatter.Serialize之间的区别?
发布评论