.NET Serialization Ordering

后端 未结 6 901
故里飘歌
故里飘歌 2020-12-03 07:40

I am trying to serialize some objects using XmlSerializer and inheritance but I am having some problems with ordering the outcome.

Below is an example similar to wha

6条回答
  •  伪装坚强ぢ
    2020-12-03 08:21

    It looks like the XmlSerializer class serializes the base type and then derived types in that order and is only respecting the Order property within each class individually. Even though the order is not totally what you want, it should still Deserialize properly. If you really must have the order just like that you will need to write a custom xml serializer. I would caution against that beacuse the .NET XmlSerializer does a lot of special handling for you. Can you describe why you need things in the order you mention?

提交回复
热议问题