The [DataMember] attribute, on the other hand, specifies that the member is part of a data contract and is serializable by the DataContractSerializer. You can use the following properties while defining the data member attribute:
- Name: It defines the name of the data member
- Order: It sets the order of serialization and deserialization of the member
- TypeId: It sets a unique identifier for this attribute in the derived class
- IsRequired: This property gets or sets a value that instructs the serialization that the member must be present during deserializing
- EmitDefaultValue: When defined, this property value is specified whether to serialize the default value of the data member
You should apply the [DataMember] attribute in conjunction with the [DataContract] attribute to identify the members of a type that are part of the data contract.