Reputation: 1911
I have a stringbuilder that will look like something close to this smith;rodgers;McCalne etc and I would like to add each value to an arraylist. Does anyone have any C# code to show this?
many thanks
Upvotes: 3
Views: 1956
Reputation: 18741
string s = "smith;rodgers;McCalne";
//
// Split string on spaces.
// ... This will separate all the words.
//
string[] words = s.Split(";");
var a = new ArrayList<String>();
foreach (string word in words)
{
a.add(word);
}
Upvotes: 2
Reputation: 9389
myArray.AddRange(myStringBuilder.ToString().Split(';'))
That's it
Upvotes: 11