我正在嘗試在C#中創建一個例程,它將添加到多行文本框中的列表排序。完成後,可以選擇刪除所有空白行。有人能告訴我如何去做這件事嗎?這裏是我到目前爲止,但是當我選擇框不會在所有的工作,然後點擊排序:如何從C#列表中刪除空白行<string>?
private void button1_Click(object sender, EventArgs e)
{
char[] delimiterChars = { ',',' ',':','|','\n' };
List<string> sortBox1 = new List<string>(textBox2.Text.Split(delimiterChars));
if (checkBox3.Checked) //REMOVE BLANK LINES FROM LIST
{
sortBox1.RemoveAll(item => item == "\r\n");
}
textBox3.Text = string.Join("\r\n", sortBox1);
}