Re: How to specify fixed length string parameter
by Spam Catcher on 11/1/2007 2:57:00 PM
=?Utf-8?B?Z3Jva25yb2xs?= <groknroll@discussions.microsoft.com> wrote in
news:25F59F72-5E02-4931-8697-5C8B7C6234A4@microsoft.com:
> Is there a way that I can define a WebMethod with a parameter that is
> a fixed length string?
I don't think you can modify the length of a string parameter.
> I'm using VB.Net 2005 and would like to define
> a webmethod that will prevent the caller from passing a string that
> exceeds a certain fixed length. For this application if the string
> parameter exceeds the specified length it will always be an error, so
> I would like to put that rule explicitly in the contract rather than
> raise the error once I get the bad data.
That's what exceptions are for... It would be nice to declare it up front,
but it's not like the client would respect it anyways (i.e. say you have a
..NET Client, the client won't be able to enforce the string length in the
development GUI).