什么是使用[DataContract],而不是WCF [Serializable接口]的优点 [英] What are the advantages of using [DataContract] rather than [Serializable] in WCF

查看:144
本文介绍了什么是使用[DataContract],而不是WCF [Serializable接口]的优点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何优势,使用DataContract?

Any advantage to using DataContract?

推荐答案

看到一个伟大的 XmlSerializer的和DataContractSerializer的比较的丹Rigsby的博客。

See a great comparison of XmlSerializer and DataContractSerializer on Dan Rigsby's blog.

赞成的DataContractSerializer的一些要点:

Some points in favor of DataContractSerializer:

  • 比XmlSerializer的速度快约10%
  • 将系列化任何装饰的 [数据成员] - 即使它不​​是公开可见
  • 将不序列任何除非您明确告诉它(选入)
  • 您可以定义在其中的元素使用上的订单= 属性序列化的顺序 [数据成员]
  • 在不需要参数的构造函数用于反序列化
  • about 10% faster than XmlSerializer
  • will serialize anything decorated with a [DataMember] - even if it's not public visible
  • will not serialize anything unless you specifically tell it to ("opt-in")
  • you can define the order in which the elements are serialized using the Order= attribute on the [DataMember]
  • doesn't require a parameterless constructor for deserialization

这篇关于什么是使用[DataContract],而不是WCF [Serializable接口]的优点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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