【发布时间】:2013-09-30 05:11:55
【问题描述】:
我的代码在每行末尾添加分号...但我需要在richtextbox1 上的第二句话中加上) 括号。如何正确添加?
NOT:我的第二句话可以以任何单词结尾,这意味着继承 s.Endwith("no") replace ("no",");").....不是一个选项使用!
我的代码只放 ;每行结束
string[] lines = richTextBox1.Lines;
List<string> ToAdd = new List<string>();
string filter = ")";
foreach (string s in lines)
{
string hold = s;
if (s.EndsWith(")"))
hold = s.Replace(filter, ";");
}
richTextBox1.Lines = ToAdd.ToArray();
我的结果
This is my sentence (Yes);
This is my sentence (Yes) or no;
This is my sentence (Yes);
This is my sentence (Yes);
我想要这个结果:
This is my sentence (Yes);
This is my sentence (Yes) or no);
This is my sentence (Yes);
This is my sentence (Yes);
【问题讨论】:
-
if((line.Trim() + ";").Length <= 2) continue; -
我要在哪里添加这个?