Error converting string to arraylist

B

Bobby Edward

Here's my code...

Dim alKeywords As ArrayList, bKeywordFound As Boolean = False

alKeywords = CType(dr("SearchValue"), ArrayList)



dr("SearchValue") is equal to "ca xyx ha". I wanted it to convert to an
arraylist with 3 items. But I keep getting this....
Unable to cast object of type 'System.String' to type
'System.Collections.ArrayList'.

Any idea why?
 
A

Andrew Morton

Bobby said:
Dim alKeywords As ArrayList, bKeywordFound As Boolean = False
alKeywords = CType(dr("SearchValue"), ArrayList)

dr("SearchValue") is equal to "ca xyx ha". I wanted it to convert to
an arraylist with 3 items. But I keep getting this....
Unable to cast object of type 'System.String' to type
'System.Collections.ArrayList'.

Any idea why?

Do you maybe want to dr("SearchValue").Split(" "c) at some point?

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top