开发者

Is the order of items in a List preserved when deserialing from xml string using XmlSerializer?

开发者 https://www.devze.com 2023-03-20 19:47 出处:网络
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 wil

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号