Reputation: 457
In C# WCF which elements get serialized when we send data to an application? When a variable has the attribute [Data member] does that variable get serialized? I don't know exactly. And how would you check to see if the data member is serialized or not? Can any one explain with an example?
Upvotes: 0
Views: 1359
Reputation: 644
You need to put DataContractAttribute on your class, and DataMemberAttribute on any properties you wish to have serialized.
Here is an example data contract:
[DataContract]
public class MyType
{
// This property is serialized to the client.
[DataMember]
public int MyField1 { get; set; }
// This property is NOT serialized to the client.
public string MyField2 { get; set; }
}
Upvotes: 1
Reputation: 4461
Basically all public properties of your returned object are serialized but only those properties that have attribute DataMember are visible or exposed to your client application without this attribute you cannot access them from your client.
Upvotes: 0
Reputation: 28728
The following members are normally serialized
get
and set
accessor DataMember
Upvotes: 1