WCF has a default serializer called DataContractSerializer.
It operates in an opt-in mode that is the opposite of the XMLSerializer. In the
DataContractSerializer member that are part of the DataContract must be
explicitly marked as such, whereas with the XMLSerializer, members are assumed
to be in the Data Contract unless explicitly marked as opting out.
The following code use the opt-out approach of the
XMLSerializer to prevent the field shown in bold from being serialized
[Serializable()]
public class student
{
public string PhoneNo;
public string email;
[NonSerialized()]
public string
address;
}
The
following code uses the opt-in approach of the DataContractSerializer:
public class CompositeType
{
[DataMember]
public string
PhoneNo;
[DataMember]
public string email;
public string Address;
}