Take the 2-minute tour ×  How can I restrict the size of data in
wcf?  assume that I have a string which should be less than 256,
how can I enforce it? for example I have:  class  DataExample
public string Name;  How can I inform and enforce the client
that the Name should be less than 256 char?  share|improve this
question add comment  1 Answer  Through the datamember /
datacontract tags, to my knowledge, you can't. There are a few
things you can do on the data contract, like require an
attribute to be present etc but they're quite limited.
share|improve this answer Any other option? Not using
DataContract or DataMember. –  mans May 11 '12 at 9:16 custom
code in your setter to return a faultexception - but nothing
thats 'built in'. –  Chris May 11 '12 at 9:19 add comment  Your
Answer