How can I add stringbuilder (semi colon delimited) values to arraylist in C#?
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
myArray.AddRange(myStringBuilder.ToString().Split(';'))
That's it
myStringBuilder.ToString().Split(';').ToList()
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);
}
An example is here
精彩评论