更新时间:2023-11-24 23:37:40
我敢打赌你有一个具有实际 int
属性的数据契约:
I bet you have a data contract that has the actual int
property:
public int YourProperty ......
以及旁边的 YourPropertySpecified
属性:
public bool YourPropertySpecified ......
由于 int
不能为 null,WCF 无法区分您是否定义了一个值 - 您需要告诉它.
Since an int
cannot be null, WCF cannot distinguish whether or not you have defined a value - you need to tell it.
因此,如果您使用 int
属性并为其设置值 - 您还需要将其随附的 YourPropertySpecified
属性设置为 true:
So if you use an int
property and set a value to it - you also need to set its accompanying YourPropertySpecified
property to true:
yourData.YourProperty = 42;
yourData.YourPropertySpecified = true;
通过这个额外的步骤,int
值应该可以很好地到达服务器
With this extra step, the int
values should arrive at the server just fine