DataContract: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 schemeNow it's time to understand the properties DataContract and DataMember attribute. The following Table shows DataContract Properties
C# Corner. All contents are copyright of their authors.