Can an internal setter of a property be serialized?

前端 未结 6 978
盖世英雄少女心
盖世英雄少女心 2020-12-07 17:32

Is there any way to serialize a property with an internal setter in C#?
I understand that this might be problematic - but if there is a way - I would like to know.

6条回答
  •  渐次进展
    2020-12-07 17:49

    You can implement IXmlSerializable, unfortunately this negates the most important benefit of XmlSerializer (the ability to declaratively control serialization). DataContractSerializer (xml based) and BinaryFormatter (binary based) could be used as alternatives to XmlSerializer each having its pros and cons.

提交回复
热议问题