How to set minOccurs to 1

后端 未结 3 1191
慢半拍i
慢半拍i 2021-01-15 16:09

I\'m building an ASP.NET web service.

I\'ve got my code defined as below, but I can\'t figure out how to the the wsdl to specify the minOccurs of the FirstName and

3条回答
  •  长发绾君心
    2021-01-15 16:42

    Strings are reference types and so by definition nullable. If your property was an integer minoccurs would have been 1.

    You can force the Serializer not to allow it to be null, by putting. [XmlElement("name", IsNullable=false)]
    above the property.

    Edit: I meant reference types instead of value types. Thnx Joren!

提交回复
热议问题