我得到这个错误转换C#.NET对象数组到另一个
错误不能类型
TestMVC.GetServiceRequests.serviceRequests[]
转换为System.Collections.Generic.IEnumerable<TestMVC.Models.ServiceRequest>
我想.NET对象数组从web服务复制到其他.NET c#对象数组和它们都具有相同的结构。
我试过类型转换,但这没有奏效。
var serviceRequest = svcClient.GetServiceRequests(getServiceRequest).responseData;
return (IEnumerable<ServiceRequest>) serviceRequests;
ServiceRequest[] serviceRequests = new ServiceRequest[]
{
new ServiceRequest { customerName = "Customer123", contactName = "Pat Nelson", vin = "4DRBUAFN75A977722", unitNo = "275", serviceRequestId = "1", requestedDate = "08/08/15", requestedTime = "PM", connectCompleted = "true",
captureCompleted = "false", collectCompleted = "false", agreeCompleted = "false", updateDate = "08/17/2015", createDate = "08/17/2015", note = "note note note note note note note note note note note note note note note note note note note note note note note note note note ", userId = "yyy1ri3"},
new ServiceRequest { customerName = "Customer456", contactName = "Pat Nelson", vin = "1HSMTAAN1DH328986", unitNo = "325", serviceRequestId = "2", requestedDate = "09/01/15", requestedTime = "AM", connectCompleted = "false",
captureCompleted = "true", collectCompleted = "true", agreeCompleted = "false", updateDate = "08/17/2015", createDate = "08/17/2015", note = "note note note note note note note note note note note note note note note note note note note note note note note note note note ", userId = "yyy1ri3"},
};
请发表实际的代码。 – Dai
发布您的代码? –
你使用什么样的Webservice? WCF或其他东西? – NineBerry