BinaryFormatter是否应用任何压缩? [英] Does BinaryFormatter apply any compression?

查看:308
本文介绍了BinaryFormatter是否应用任何压缩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当.NET的 BinaryFormatter 用于序列化对象图,是否应用了任何类型的压缩?

When .NET's BinaryFormatter is used to serialize an object graph, is any type of compression applied?

编辑 - 如果字符串已被嵌入,请按住。 NET,没有必要担心重复的字符串,对吧?

Edit - Hold on, if strings are interned in .NET, there's no need to worry about repeated strings, right?

推荐答案

不,它不提供任何压缩,使用 自己压缩输出, GZipStream 类型。

No, it doesn't provide any compression but you can compress the output yourself using the GZipStream type.

编辑 Mehrdad 有一个很好的例子,这个技术在他的回答如何使用gzip压缩.net对象实例

Mehrdad has a wonderful example of this technique in his answer to How to compress a .net object instance using gzip.

编辑2:字符串可以被嵌入,但这并不意味着每个字符串都是被嵌入。我不会对如何或为什么CLR决定实体字符串做任何假设,因为它可以从版本改变(并已更改)。

Edit 2: Strings can be interned but that doesn't mean that every string is interned. I wouldn't make any assumptions on how or why the CLR decides to intern strings as this can change (and has changed) from version to version.

这篇关于BinaryFormatter是否应用任何压缩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆