我的代码在每行的末尾添加分号......但我需要在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);