Is having 'minOccurs=0' sufficient to cause .NET to create a xxxSpecified field

本秂侑毒 提交于 2019-12-24 15:21:54

问题


I have consumed a WSDL and one of the fields was from a enum type and in the generated reference.cs it created two fields for this:

The field was called 'IsPayment' and it generated one called IsPaymentField and IsPaymentFieldSpecified

I read from this answer: Why isn't my public property serialized by the XmlSerializer?

That items with public bool xxxSpecified with value of false are not serialized

So I manually in code set it to True and it worked.

But what has caused this field to generate this Specified field when every other field that uses the same struct does not?

the only difference I can see is in the WSDL this field has explicitly got: nillable=true minOccurs=0

all other fields have nothing, but the enum itself is defined as: nillable="true"

So the only difference is minOccurs on my value?

Thanks.

来源:https://stackoverflow.com/questions/36900089/is-having-minoccurs-0-sufficient-to-cause-net-to-create-a-xxxspecified-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!