DataContract is under namespace System.Runtime.Serialization. During design time, DataContract Attribute is used to indicate which class should be represented as XSD.
DataMember Attribute indicates which class member to be used in external representation.
During my discussion with many people, they think about DataContract with a different passion. They say DataContract is used for communicating with a client and service. Do you think that answer is correct? The answer is partially correct, because in .Net serialization and deserialization will happen quickly and that's why we use DataContract to interact with Client and Service.
The Syntax of DataContract is shown in the following figure

By looking at the figure, we can define DataContract attribute to Class, Struct and Enum. DataContract attribute contains two get and set properties as Name and Namespace.
The following figure shows how the .Net implementation is used in a XML scheme

Now it's time to understand the properties DataContract and DataMember attribute.
The following Table shows DataContract Properties
| DataContract Property | Description |
| Namespace | It is used to get or set the namespace for the DataContract attribute of this type. |
| Name | It is used to get or set the name for DataContract attribute of this type. |
The following table shows DataMember properties
| DataMember Property | Description |
| Order | It is used to get or set the order of serialization and deserialization of a member. |
| ISRequired | It instructs the serialization engine that member must be present while reading or deserializing. |
| Name | It gets or sets the DataMember name. |
| EmitDefaultValue | It will specify whether the default value to be serialized. |








Prateek SrivastavaPosted Oct 6, 2018, 4:33 AM
You have not enabled metadata endpoint so this will give error while using svcutil..
m_murugesanPosted Dec 17, 2015, 4:07 AM
why is code download line missing?
Anil KumarPosted Oct 5, 2015, 3:17 AM
Thanks for posting..
Mahesh ChandPosted Dec 8, 2010, 7:19 AM
Thanks for sharing
GauransheditedPosted Dec 8, 2010, 7:07 AMEdited Dec 8, 2010, 7:08 AM
Thanks man, Really good article here on http://www.c-sharpcorner.com/