WCF: DataMember attribute on property vs. member

后端 未结 7 1996
北海茫月
北海茫月 2021-01-30 20:27

In wcf, what is the difference between applying the DataMember attribute on a property

private int m_SomeValue;

[DataMember]  
public int SomeVal         


        
7条回答
  •  隐瞒了意图╮
    2021-01-30 20:41

    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).

提交回复
热议问题