Is the order of items in a List preserved when deserialing from xml string using XmlSerializer?
I am using XmlSerializer to deserialize an XML string into a Generic List. The des开发者_C百科erialization works fine. However, I just want to make sure if the order of the items in the XML string will be maintained in the resulting Generic List. i.e. with respect to siblings in the XML string. i.e.
<Items>
<Item>A</Item>
<Item>B</Item>
</Items>
"A" will always be the first item in the List and "B" always the second. Didn't find any articles or information on the web about the order of the resulting deserialized XML elements?
Simply put, yes. The order of elements is significant in XML, and is therefore preserved when deserializing.
Additionally, since the order of items in a list or array is significant, it must be preserved in order for XML serialization to be meaningful.
精彩评论