本文介绍了"格式化"和"串行" - 术语之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有些东西在.NET中被称为格式化。 - 的BinaryFormatter SoapFormatter

Some things in .NET are called "formatters" - BinaryFormatter, SoapFormatter.

其他被称为序列化 - 的XmlSerializer 的DataContractSerializer

Others are called "serializers" - XmlSerializer, DataContractSerializer.

为什么不同?

推荐答案

一个有点脆弱,但有一个细微的差别。有17个具体的类在.NET框架格式的XML。这些格式化都被隐藏,你会得到一个实例他们的方法类似XmlWriter.Create()。相同的DataContractSerializer,实际的格式化,比方说,一个的XmlDictionaryWriter实例来完成。

A bit tenuous, but there is a subtle difference. There are 17 concrete classes in the .NET framework that format XML. These formatters are all hidden, you get an instance to them with a method like XmlWriter.Create(). Same for DataContractSerializer, the actual formatting is done by, say, an XmlDictionaryWriter instance.

没有这样间接为的BinaryFormatter或SoapFormatter,他们照顾格式化自己。换言之,一个格式化的格式,一个串行器使用一个格式化器。

No such indirection for BinaryFormatter or SoapFormatter, they take care of the formatting themselves. In other words, a Formatter formats, a Serializer uses a formatter.

这篇关于"格式化"和"串行" - 术语之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:26