在WCF,什么是应用数据成员
属性在属性之间的区别
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 {...}
}
在一般情况下,你应该赞成申请将DataMember属性的财产,而不是在私人领域。该属性应用到外地,而不是唯一的原因是,如果该属性是只读的(即它有没有setter)。
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).