wcf DataContractSerializer is an Opt-In and Opt-Out serializer. What is opt in serializer


Example

/// <summary>
/// Defines a student.
/// </summary>
[DataContract]
public class Student
{
    /// <summary>
    /// Gets or sets the student number.
    /// </summary>
    [DataMember]
    public string StudentNumber { get; set; }

    /// <summary>
    /// Gets or sets the first name.
    /// </summary>
    [DataMember]
    public string FirstName { get; set; }

    /// <summary>
    /// Gets or sets the last name.
    /// </summary>
    [DataMember]
    public string LastName { get; set; }

    /// <summary>
    /// Gets or sets the marks obtained.
    /// </summary>
    public int MarksObtained { get; set; }
}

/// <summary>
/// A service that provides the operations for students.
/// </summary>
[ServiceContract]
public interface IStudentService
{
    //Service contract code here.
}

In above code StudentNumber, FirstName, LastName properties of Student class are explicitly marked with DataMember attribute as oppose to MarksObtained, so MarksObtained will be ignored. From ignored it means that MarksObtained wont be the part of data going across the wire to / from this service.