Can an internal setter of a property be serialized?

前端 未结 6 975
盖世英雄少女心
盖世英雄少女心 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

    If you're doing "default" XML serialization it will only look at public properties. Implementing IXmlSerializable will get you control over exactly what is serialized. If you're doing "standard" .NET serialization, it will look at fields - not properties, so your object will still be correctly serialized without any need for implementing any extra interfaces.

提交回复
热议问题