c#: how to hide a field which is used only for XML serialization retrocompatibility?
问题 The field is used only during the serialization / deserialization process but I would like to immediately encapsulate it and hide from the class. Is it possible? 回答1: Basically, no. XmlSerializer only works with public members, so you can't make it internal or private . You can add some attributes to make it less glaring especially in UIs that data-bind: [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public int Foo {get; set; } but that only masks it. You could also look at