0
這是我第一次使用.net的經驗,所以問題可以很簡單。我有Web服務的Web方法:Web服務客戶端類型鑄造
[WebMethod(CacheDuration = 30,
Description = "Returns an Array of Clients.")]
public ClientData[] GetClientData(int Number)
{
ClientData[] Clients = null;
if (Number > 0 && Number <= 10)
{
Clients = new ClientData[Number];
for (int i = 0; i < Number; i++)
{
Clients[i].Name = "Client " + i.ToString();
Clients[i].ID = i;
}
}
return Clients;
}
我創建這個Web服務客戶端:
LocalService.Service1 service = new LocalService.Service1();
String data = service.HelloWorld();
ClientData[] clients = service.GetClientData(3);
我宣佈在Web服務和Web客戶端的結構datetype:
public struct ClientData
{
public String Name;
public int ID;
}
現在,我得到了錯誤的Cleint:
Error 1 Cannot convert type 'ConsoleApplication1.LocalService.ClientData[]' to 'ConsoleApplication1.ClientData[]' C:\Users\ademidov\documents\visual studio 2010\Projects\WebService1\ConsoleApplication1\Program.cs 22 36 ConsoleApplication1
我該如何解決它?
你有一個'LocalService.ClientData'類型嗎?檢查'service.GetClientData(3);'的返回類型 –