Difference between DataContractSerializer vs XmlSerializer

后端 未结 2 1158
抹茶落季
抹茶落季 2021-02-04 11:06

I was going through WCF Fundamentals, Can anybody tells that under which scenarios should we use DataContractSerializer and XmlSerializer?

2条回答
  •  抹茶落季
    2021-02-04 11:51

    1. DataContractSerializer is better performance over Xmlserializer. This is because DataContratSerializer explicitly shows the which fields or properties are serialized into XML.

    2. DataContractSerializer can able to serialize types that implements Idictionary whereas XML serializer not.

    3. DataContractSerializer serializes all members which are marked with [DataMember] attribute even if member is marked private. XML serializer serialize only public members.

    These are some important difference.

提交回复
热议问题