Replacement for XML Serialization

后端 未结 6 2072
梦毁少年i
梦毁少年i 2020-12-24 13:17

I have code using XmlSerializer to serialize/deserialize a data structure for persistance. I\'ve read and heard in several places here on StackOverflow that

6条回答
  •  既然无缘
    2020-12-24 13:34

    If you can use .Net 3.5 (preferably SP1), I'd look into the DataContractSerializer. Although it is less configurable than the XmlSerializer, it's faster, easier to work with (at least in my experience) and more portable (i.e. for web services). SP1 changed the default behaviour of it to be opt-out, so you can serialize any class without having to explictly define attributes on everything you need to serialize.

    I would recommend thoroughly reading the documentation on it though before investing in it as a change. Depending on how customized your serialization is, it may not work for you.

提交回复
热议问题