0

I have web service that should receive param ArrayList

[WebMethod] 
public void SelectPatches(ArrayList selectedPatches){}

But when I call this method from client Visual Studio return error:

Cannot convert from 'System.Collections.ArrayList' to 'object[]'

Is it possible to pass parameter with type ArrayList to Web Service?

2 Answers 2

3

Don't use non-generic collections. Use generic, at least List<object>.

Web method should accept array of any type, thus use ToArray() extension method.

Sign up to request clarification or add additional context in comments.

1 Comment

Really, a more specific typed list is preferable. A web-service wont love "object"
1

You can use arrayList.ToArray() (MSDN) to convert an ArrayList to an object[].

You can also use arrayList.ToArray(Type) (MSDN) to convert an ArrayList to an array of the specified type, instead of having to cast each element individually.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.