开发者

How can I add stringbuilder (semi colon delimited) values to arraylist in C#?

开发者 https://www.devze.com 2023-01-13 16:26 出处:网络
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 th

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

精彩评论

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