Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Arraylist problems
Message
De
16/03/2009 13:52:52
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
À
16/03/2009 13:41:14
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01388448
Message ID:
01388456
Vues:
43
>I have an array list (laData) that I have parsed a CSV file into. I end up with the following:
>
>The first element of laData containes "test","test2"
>The 2nd element of laDAta containes "test3","test4"
>
>I want to be able to move through the arraylist, get the 2 fields from each element and work with them. I can't seem to find the proper method for doing this.
>
>I assumed a simple laData[0][0].tostring() would have returned "test". but no luck.
>
>Any ideas on this?
>
>thanks in advance
>
>Alan Wyne

First, it might be easier (and better performance?) to use either a string array or a String List class instead of an ArrayList filled with strings.

Try this:
foreach (string myRecord in laData.Items)
{
   //use the String.Split method to return an array of items in each record.
   string[] myFields = myRecord.Split(',');
   Msgbox(myFields[0]);
   Msgbox(myFields[1]);
}
Very fitting: http://xkcd.com/386/
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform