datacontract serialization in WCF

datacontract serialization is faster than xml serialization
 OR
datacontract serialization is 10% faster than xml serialization

One of friend asked me the above question but i have not got any proper answer of the above question. Can you guys explain, what is the reason why datacontract serialization is 10% faster than xml serialization
LVL 1
dynamicweb09Asked:
Who is Participating?
 
Miguel OzConnect With a Mentor Software EngineerCommented:
Datacontract serialization is faster than xml serialization because the former is optimized to serialize properties that are identified as data members. XmlSerializer inspects all fields of an object using reflection and implement custom xml serialization (e.g. control of the XML structure)  thus it is slower than Datacontract serialization

Notes: 1) You can not tell how fast because it will depend on your object.
2) For more information see MS guidelines
3) Notice that guidelines recommendations: "AVOID supporting runtime serialization or XML serialization just for general persistence reasons. Prefer data contract serialization instead" and "XML serialization technology has been superseded by the Data Contract Serialization"
0
 
p_davisCommented:
I'm not sure I understand.... Data Contracts serialize into an XML stream or document. So saying that question as a declarative statement is redundant.
0
 
käµfm³d 👽Commented:
I suspect by "xml serialization" the author means the XmlSerializer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.