Datacontract Attributes Serialization

Posted on by
Give More FeedbackDatacontract Serialization Attributes

Apply the DataContractAttribute attribute to types (classes, structures, or enumerations) that are used in serialization and deserialization operations by the. Download Free Software License Dependency Diagramme. If you send or receive messages by using the Windows Communication Foundation (WCF) infrastructure, you should also apply the DataContractAttribute to any classes that hold and manipulate data sent in messages. For more information about data contracts, see. You must also apply the to any field, property, or event that holds values you want to serialize. By applying the DataContractAttribute, you explicitly enable the to serialize and deserialize the data. A data contract is an abstract description of a set of fields with a name and data type for each field.

The data contract exists outside of any single implementation to allow services on different platforms to interoperate. As long as the data passed between the services conforms to the same contract, all the services can process the data. This processing is also known as a loosely coupled system. A data contract is also similar to an interface in that the contract specifies how data must be delivered so that it can be processed by an application. For example, the data contract may call for a data type named 'Person' that has two text fields, named 'FirstName' and 'LastName'. To create a data contract, apply the DataContractAttribute to the class and apply the to any fields or properties that must be serialized.