开发者

Strings with webservices. Making them not nullable?

I want to expose a web method over web services like this,

public bool AddApple(string colour);

The trouble with strings is that you can pass a value of null.

Is there a way to say that that string is non nullable?

For instance in the entity framework the property has an a开发者_开发百科ttribute like this,

[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]

Which says the string is not nullable.

Just checking, because obviously if there is no way I will just have to perform validation on it and throw an error. The only problem is that my 'parameter' is actually a very complicated object with a number of strings in it, so it will take me a while to write the code to throw errors, and I could easily miss stuff.

Thanks.


No. I don't think your can force string to be not null. You'll need to validate here.


Could you pass in Enums instead for your value of color instead of a string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜