String.split to a 2d array?

M

MattB

I have a list of states and abbreviations that I want to be able to pull
into a 2d array to bind to a control. The list looks like this:

AL:Alabama,AK:Alaska,AZ:Arizona,...

So If I take the starting and split it on the comma, it gives me a 1d
array with XX:Name in each element. Is there any easy way (like split)
to do this into a 2d array, so I end up with:

aStates(0,0)="AL"
aStates(0,1)="Alabama"

and so on...

I know a number of ways I could code this up to make it work but I'm
wondering if there's a nice quick n' dirty way using split or something
similar. Thanks!

Matt
 
P

Peter Rilling

String.Split allows you to pass in more than one delimiter. Maybe what you
could do is to figure that all even indexes are the state code and all odd
indexes are the state name.
 
M

MattB

Thanks. I considered that but decided on making a DataTable, looping
through the first array from splitting on the comma, and splitting a
second time on the colon and loading the table row that way.
Works well, I just wanted to see if I was overlooking a really easy
shortcut.

Matt
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top