WCF: DataMember attribute on property vs. member

后端 未结 7 2004
北海茫月
北海茫月 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:39

    Personally I would just use the property and completely removed the member variable all together. i.e.

    [DataMember]
    public int SomeValue
    { get; set; }
    

    The property will inexplicably create a member variable behind the scenes.

提交回复
热议问题