如何将string []更改为stringbuilder [英] how to change string[] into stringbuilder
本文介绍了如何将string []更改为stringbuilder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有C#编码,需要一组值...
所以我声明string []接受所有值……
现在我需要将string []更改为stringbuilder ...
是否有可能更改stringbuilder .....
谁能给我一个解决方案
I have C# coding which takes group of values...
So I declare string[] to take all values......
Now I need to change string[] into stringbuilder...
Is there any possibility to change stringbuilder.....
Can anyone pls give me a solution
推荐答案
^ ]
StringBuilder sb = new StringBuilder();
string[] StringArray = new string [] {"one","two","three"};
foreach(string s in StringArray)
{
sb.Append(s);
}
string[]
是字符串的集合,StringBuilder
是单个字符串,因此,如果不指定方式,则不可能进行转换,因为一个是二维的,而另一个是二维的是一维的.
您可以:
string[]
is a collection of strings,StringBuilder
is a single string, so converting is not possible without specifying how, since one is 2 dimensional and the other is 1 dimensional.
You can :
string[] strings ;
StringBuilder sb = new StringBuilder();
foreach (string s in strings)
sb.Append(s);
这篇关于如何将string []更改为stringbuilder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文