I would like to pass some parameters to a web method as an array. The web method’s signature does not have the params keyword.
I have a variable number of parameters (as the web method accepts) so I cannot put the array into n single variables.
How can this be done?
paramsis just syntactic sugar, why not just do something like this:The method signature on the web service side would just be:
If you post your web method maybe I can provide a better answer.
EDIT
If you can’t modify the web method signature, then I would use an extension method to wrap the difficult to call web service. For example, if our web service proxy class looks like:
Then you could create an extension method that accepts the string array as
paramsand makes the call toMyWebService.You could then call your web service using the extension method you created (just be sure to add a
usingstatment for the namespace where you declared you extension method):