BinaryWriter和BinaryFormatter.Serialize之间的区别?

编程入门 行业动态 更新时间:2024-10-28 10:31:32
本文介绍了BinaryWriter和BinaryFormatter.Serialize之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是对象序列化的新手,在学习如何使用 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之间的区别?

本文发布于:2023-05-25 00:28:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/218694.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区别   BinaryWriter   BinaryFormatter   Serialize

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!