In wcf, what is the difference between applying the DataMember
attribute on a property
private int m_SomeValue;
[DataMember]
public int SomeValue {
get {...}
set {...}
}
instead of a member variable
[DataMember]
private int m_SomeValue;
public int SomeValue {
get {...}
set {...}
}
?
In general, you should favor applying the DataMember attribute on the property, rather than on the private field. The only reason to apply the attribute to the field instead is if the property were read-only (i.e. it has no setter).