In wcf, what is the difference between applying the DataMember
attribute on a property
private int m_SomeValue;
[DataMember]
public int SomeVal
In theory, and as long as you keep m_SomeValue
always equal to SomeValue
(like a simple getter/setter), nothing. Other than the name of the variable exposed by the WCF. (Obviously, if you tag the m_
variable, then your proxy class will also have the same m_
name. The proxy class will generate a public property whether you use a public/protected/internal/private field or property.
However, if you have any special logic in your accessors that may modify the value returned (ToUpper()
ing a string, for example), then you would return a different value.