本文介绍了要在C#的文本框中显示的几个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有几个文件读取的字符串.
现在,我必须在具有多行属性的单个文本框中显示它们
下面我给了代码
Hi All,
I have several string which I got from a file read.
Now I have to show them in a single text box which have multi-line properties
below I had given code
string FstArray = splite[0];
string SndArray = splite[1];
textBox2.Text = FstArray;
在特定的文本框中,只有第三,第四和第七个字符串应该一个接一个地出现(不是同一行)
感谢所有人
Indrajit
only third,fourth and seventh string should come one by one (not same line) in a particular text box
Thanks To All
Indrajit
推荐答案
textBox2.Text = String.Join(System.Environment.NewLine, splite)
void PopulateTextBox(string[] source, TextBox destination) {
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int count = 0;
foreach(string line in source) {
sb.Append(line);
if (count < source.Length - 1)
sb.Append(System.Environment.NewLine);
++count;
}
destination.Text = sb.ToString();
}
textBox2.Text = FstArray + Environment.NewLine + FstArray;
这篇关于要在C#的文本框中显示的几个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!