DataContractSerializer: How to serialize classes/members without DataContract/DataMember attributes

后端 未结 3 1164
有刺的猬
有刺的猬 2020-12-16 03:36

DataContractSerializer requires classes and members to be marked with the DataContract and DataMember attributes. However, in my case

3条回答
  •  隐瞒了意图╮
    2020-12-16 04:36

    I believe it is possible. If you implement the ISerializable interface then the serializer users your implementation instead of the attributes. Although I think you will still have to mark the class [Serializable].

    Its a little more work than adding attributes but it does work.

提交回复
热议问题