What are the differences between the XmlSerializer and BinaryFormatter

前端 未结 5 1957
-上瘾入骨i
-上瘾入骨i 2020-11-29 16:54

I spent a good portion of time last week working on serialization. During that time I found many examples utilizing either the BinaryFormatter or XmlSerializer. Unfortunatel

5条回答
  •  失恋的感觉
    2020-11-29 17:36

    The XML Serializer produces XML and also an XML Schema (implicitly). It will produce XML that conforms to this schema.

    One implication is that it will not serialize anything which cannot be described in XML Schema. For instance, there is no way to distinguish between a list and an array in XML Schema, so the XML Schema produced by the serializer can be interpreted either way.

    Runtime serialization (which the BinaryFormatter is part of) serializes the actual .NET types to the other side, so if you send a List, the other side will get a List.

    That obviously works better if the other side is running .NET.

提交回复
热议问题