XmlSerializer vs DataContractSerializer: Serialization in Wcf

本文探讨了.NET中XML序列化器与DataContract序列化器的优缺点。XML序列化器自.NET 1.0以来便存在,而DataContract序列化器在.NET 3.0中引入。对于WCF应用,推荐使用DataContract序列化器;若需完全控制XML输出,则XML序列化器更佳。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这篇文讲得不错,可惜居然要翻墙。

摘录:

The XmlSerializer has been in .Net since version 1.0 and has served us well for everything from Remoting, Web Services, serializing to a file, etc. However in .Net 3.0 the DataContractSerializer came along.? And all of a sudden a lot of guidance suggests that we should use it over the old tried and true XmlSerializer. Wcf even uses this as the default mechanism for serialization.? The question is, “Is it really better?”.? The verdict is yes, and no.? Like most things it depends on your implementation and what you need.? For Wcf, you should prefer to use the DataContractSerializer.? If you need full control over how the xml looks though, you should go back to the XmlSerializer.

Lets look at the both of these in detail and leave it up to you to decide which is best for your implementation.? Here are a few of the advantages and disadvantages of each of them:

。。。。。。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值