WCF: DataMember attribute on property vs. member

后端 未结 7 2013
北海茫月
北海茫月 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条回答
  •  猫巷女王i
    2021-01-30 20:51

    If add [DataMember] on private int m_SomeValue, this member can not be serialization,so must be add it on public int SomeValue.

    [DataMember]  
    private int m_SomeValue;
    
    public int SomeValue {
      get {...}
      set {...}
    }
    

    the code of above can not be get value in the client if you use it through WCF.

提交回复
热议问题