开发者

ASP.NET Cast ArrayList of objects to custom Objects

开发者 https://www.devze.com 2023-03-26 19:26 出处:网络
Hey Just getting the following error Unable to cast object o开发者_StackOverflowf type \'System.Object[]\' to type \'OrderService.webdirect_WebLinesRow[]\'.

Hey Just getting the following error

Unable to cast object o开发者_StackOverflowf type 'System.Object[]' to type 'OrderService.webdirect_WebLinesRow[]'.

On the line

webdirect(web_companyID, web_locationCode, web_customerNumber, web_orderNumber, web_orderReference, web_orderDate, webLinesArray.ToArray(), o_Company, o_LocationCode, o_CustomerNumber, o_OrderNumber, o_OrderStatus, o_OrdDescrip, webRespArray)

I created the webLinesArray.ToArray() array as such

Dim webLinesArray As New ArrayList()

Am I missing an additional cast or something ?


Try out using System.Linq:

webLinesArray.Cast(of WebLinesRow)().ToArray()

instead of

webLinesArray.ToArray()

BTW,

why are you using legacy ArrayList? Try out generic List<T>

0

精彩评论

暂无评论...
验证码 换一张
取 消