DataMemberAttribute Class
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
When applied to the member of a type, specifies that the member is part of a data contract and is serializable by the DataContractSerializer.
Assembly: System.Runtime.Serialization (in System.Runtime.Serialization.dll)
The DataMemberAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | EmitDefaultValue | Gets or sets a value that specifies whether to serialize the default value for a field or property being serialized. |
![]() | IsRequired | Gets or sets a value that instructs the serialization engine whether the member must be present in the serialized data when it is being deserializing. |
![]() | Name | Gets or sets a data member name. |
![]() | Order | Gets or sets the order of serialization and deserialization of a member. |
| Name | Description | |
|---|---|---|
![]() | Equals | Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Returns the hash code for this instance. (Inherited from Attribute.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
Apply the DataMemberAttribute attribute in conjunction with the DataContractAttribute to identify members of a type that are part of a data contract. One of the serializers that can serialize data contracts is the DataContractSerializer.
The data contract model for Windows Phone is an opt-out model. This means that the members are serialized by default unless the IgnoreDataMemberAttribute is applied to a field or property explicitly to specify that the member value is not to be serialized.
By default, the CLR member name is used as the name of the data member. By setting the Name property, you can customize the name of the data member. This can be used to provide a name that may not be allowed as a CLR member name. When mapping to XML using the DataContractSerializer, this name is used as the name of the schema element in a type.


