1. Back To Blog

WCF interview questions with answers :- What is DataContractSerializer and how it's different from XmlSerializer ?

This interview question is taken from .NET interview question and answer book published by Bpb publications.

 

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

XmlSerializer

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

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 serialize not only properties but also fields.

It can also serialize nonpublic members

It can serialize properties with only Get Accessor

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

Faster

Slower compare to DataContractSerializer

It can only work in WCF

It can work for WCF and Webservices (asmx)

 

This WCF interview question with answer is sponsored by www.questpond.com

 

Below is a simple WCF interview question with answer video which talks about can we overload WCF operation contract methods.

 

Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social