开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜