top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is DataContractSerializer and How its different from XmlSerializer?

+1 vote
436 views
What is DataContractSerializer and How its different from XmlSerializer?
posted Mar 7, 2017 by Jdk

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

First of all Serialization is a process of translating Object state into a format that can be stored and if want transmitted.

In this article I would like to talk about difference between XmlSerializer and DataContractSerialzier.

DataContractSerializer

Best when we want to serialize some of the properties in object.

It uses Opt-In approach. It means we have to explicitly specify which properties need to be serialized

It can serialize not only properties but also fields.

It can serialize properties with only Get Accessor

Faster

It can only work in WCF

XmlSerializer

Best when we want to serialize most of the properties in object.

It used Opt-out approach. It means we have to explicitly specify which properties you don't want to serialize

It can also serialize nonpublic members

It can only serialize public properties which must have both Get and Set Accessor.

Slower compare to DataContractSerializer

It can work for WCF and Webservices (asmx)

answer Mar 8, 2017 by Sathish Kumar
...