Can I use DataContract and Serializable together?

北慕城南 提交于 2019-12-02 20:23:19

I found an article on MSDN according to this we can use both attribute DataContract and Serializable together.

With [Serializable], all fields become part of the data contract (unless they are marked with [NonSerialized]). With [DataContract], only members marked with [DataMember] are included. Note that if a type has both [DataContract] and [Serializable] attributes on it, it will use the [DataContract] mapping

http://msdn.microsoft.com/en-us/magazine/cc163569.aspx

if the problem is in naming why don't you use

[XmlElement(ElementName = "Name")]
public string Name { get; set; } 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!