Why does a Web Service DataMember's Specified Attribute need to be set for int and Data but not for String

前端 未结 3 1916
甜味超标
甜味超标 2020-12-09 06:24

I have created a web service via WCF. Then I exposed it as a web service to make it usable with a .NET 2.0 application. I created some DataContract with DataMember that coul

3条回答
  •  既然无缘
    2020-12-09 07:20

    The default parameters for the DataMember attribute are:

    bool EmitDefaultValue (default true)
    bool IsRequired (default false)
    

    If the property you are exposing is a non-nullable value type you should use:

    [DataMember(IsRequired = true)]
    public int InvoiceNo;
    

提交回复
热议问题