【发布时间】:2013-11-06 05:43:46
【问题描述】:
我已通过 StackOverflow 和 Google 搜索转换,但不幸的是我无法获得解决方案。一切都与我想要的相反。即,将int[] 转换为List。
问题
我的[WebMethod] 中有此代码。
[WebMethod]
public int MyMethodWS(int N, List<int> M)
{
}
现在我有一个控制台应用程序,它通过使用此 URL 引用此服务:
http://localhost:61090/MyMethod.asmx?WSDL
我的控制台应用程序中有此代码:
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);
当我运行这段代码时,我收到了这个错误:
#1: '
MyMethod.MyMethod.MyMethodWS(int, int[])' 的最佳重载方法匹配有一些无效参数。#2: 参数 2:无法从 '
System.Collections.Generic.List<int>' 转换为 'int[]'
问题
- 我在那里只使用了
List。但是为什么它试图转换为int[]? - 目前,WebService 和 Console Application 都在同一个解决方案中运行。这是个问题吗?我应该使用不同的解决方案,还是完全使用不同的 Visual Studio 2012 实例?
【问题讨论】:
标签: c# list visual-studio-2012 int