I have searched through StackOverflow and Google for the conversion, but unfortunately I was unable to get the solution. Everything was the opposite of what I wanted. i.e., Conversion of an int[] to List.
Problem
I have this code in my [WebMethod].
[WebMethod]
public int MyMethodWS(int N, List<int> M)
{
}
And now I have a Console Application, that references this service by using this URL:
http://localhost:61090/MyMethod.asmx?WSDL
I have this code in my Console Application:
int N;
List<int> M = new List<int>();
// Some crazy user input coding.
// Ultimately you will have non-empty M list and N int.
MyMethod.MyMethodWS DA = new MyMethod.MyMethodWS();
Sum = DA.MyMethodWS(N, M);
When I run this code, I am getting this error:
#1: The best overloaded method match for '
MyMethod.MyMethod.MyMethodWS(int, int[])' has some invalid arguments.#2: Argument 2: cannot convert from '
System.Collections.Generic.List<int>' to 'int[]'
Questions
- I have used only
Listthere. But why is it trying to convert asint[]? - Currently the WebService as well as Console Application, both run in the same Solution. Is it a problem? Should I use different solutions, or different instances of Visual Studio 2012 altogether?