By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,699 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,699 IT Pros & Developers. It's quick & easy.

split a string into an arraylist?

P: n/a
If I try splitting a string into an arraylist

Dim arrList As New ArrayList
arrList = Split("a,b,c", ",")

I get this error: Value of type '1-dimensional array of String' cannot
be converted to 'System.Collections.ArrayList'.

How can I split a string into an arraylist?

Thanks

Feb 15 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Mad Scientist Jr" <us*************@yahoo.com> schrieb
If I try splitting a string into an arraylist

Dim arrList As New ArrayList
arrList = Split("a,b,c", ",")

I get this error: Value of type '1-dimensional array of String'
cannot be converted to 'System.Collections.ArrayList'.

How can I split a string into an arraylist?


arrlist.addrange(Split("a,b,c", ","))

Armin

Feb 15 '06 #2

P: n/a
"Mad Scientist Jr" <us*************@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
If I try splitting a string into an arraylist

Dim arrList As New ArrayList
arrList = Split("a,b,c", ",")

I get this error: Value of type '1-dimensional array of String' cannot
be converted to 'System.Collections.ArrayList'.


Aren't Constructors Wonderful things?

Creating a new ArrayList /based on/ a String array:

Dim arrList As New ArrayList( "a,b,c".Split( ","c ) )

or, to split by a multiple-character delimiter:

Imports VB=Microsoft.VisualBasic

Dim arrList As New ArrayList( VB.Split( "a<>b<>c", "<>" ) )

HTH,
Phill W.
Feb 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.