Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
String collection versus string array
Message
De
17/08/2009 18:05:31
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
17/08/2009 16:11:57
John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01418535
Message ID:
01418560
Vues:
43
>>Hi all,
>>
>>I was just pondering the use of List collection versus a string array when used as a simple collection of string items. For instance how would the reliability of problems be if I did this:
>>
>>List<string> myList = new List<string>
>>myList.Add("One");
>>myList.Add("Two");
>>etc..
>>
>>if (myList.Count > 0)
>> int mycount = myList.Count;
>>
>>versus
>>
>>string[] myStrings = new string[];
>>myStrings[0] = "One";
>>myString[1] = "Two";
>>etc;
>>
>>if (myString.Length > 0)
>>  int mycount = myString.Length;
>>
>>
>>The reason for my question is I have some methods that expect a string array to be passed in. I would much rather create my arguments out of collections but I would have to convert them all some how or re-write the methods that use a string array.
>>
>>By the way, what is the best way to convert from a collection to an array - both of strings of course?
>>
>>Tim
>
>5 second google gave me this: http://dotnetperls.com/convert-list-array

Thanks John
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform