0

Hey Just getting the following error

Unable to cast object of 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 ?

1 Answer 1

2

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>

Sign up to request clarification or add additional context in comments.

5 Comments

@StevieB : linq is supported in vs2008 / .net framework 3.5. It is a standalone library that has no dependency on (asp.net ???) mvc.
yeah I tried webLinesArray.Cast<WebLinesRow>().ToArray() but getting error Cast is not a member of System.Collections.ArrayList
Cool tried that but now getting Error 6 Type parameter 'TResult' for extension method 'Public Function Cast(Of TResult)() As System.Collections.Generic.IEnumerable(Of TResult)' defined in 'System.Linq.Enumerable' cannot be inferred.
It's VB.NET so using should be Imports System.Linq and the cast should be webLinesArray.Cast(Of WebLinesRow)().
@Steve: drop ArrayList, it's not used anymore.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.