Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C从列表中删除不需要的字符#_C#_Arrays_List_Trim - Fatal编程技术网

C# 使用C从列表中删除不需要的字符#

C# 使用C从列表中删除不需要的字符#,c#,arrays,list,trim,C#,Arrays,List,Trim,我有一个多行文本框,可以将任何文本项的列表粘贴到其中,如下所示: 555-555-1212 I want's a lemon's. google.com 1&1 Hosting -,$,!,@,#,$,%,^,&,*,(,),.com,.net,.org 我旁边还有一个文本框,可以添加逗号分隔的字符串,我希望从列表中的所有项目中删除这些字符串,如下所示: 555-555-1212 I want's a lemon's. google.com 1&1 Hosting

我有一个多行文本框,可以将任何文本项的列表粘贴到其中,如下所示:

555-555-1212
I want's a lemon's.
google.com
1&1 Hosting
-,$,!,@,#,$,%,^,&,*,(,),.com,.net,.org
我旁边还有一个文本框,可以添加逗号分隔的字符串,我希望从列表中的所有项目中删除这些字符串,如下所示:

555-555-1212
I want's a lemon's.
google.com
1&1 Hosting
-,$,!,@,#,$,%,^,&,*,(,),.com,.net,.org
我正试图找出如何从我的文本框列表中的每个字符串中删除这些字符串(或我在第二个文本框中放入的任何其他字符串)

有什么想法吗?我知道如何将列表放入列表字符串,但不知道如何删除该字符串

这就是我目前所拥有的……但我得到了红色的曲线:

List<string> removeChars = new List<string>(textBox6.Text.Split(','));                 
for (int i = 0; i < sortBox1.Count; i++)
{
    sortBox1[i] = Regex.Replace(sortBox1[i], removeChars, "").Trim();
}
List removeChars=新列表(textBox6.Text.Split(',');
for(int i=0;i
结果:

5555551212
我想要一个柠檬
谷歌公司
1&1托管

文本框.行
中每行的不需要列表中的每个字符串使用

string[] replaceStrings = txtUnwanted.Text.Split(',');
List<string> lines = new List<string>(textBox1.Lines);
for (int i = 0; i < lines.Count; i++)
    foreach (string repl in replaceStrings)
        lines[i] = lines[i].Replace(repl, "");
string[]replaceStrings=txtnwanted.Text.Split(',');
列表行=新列表(textBox1.lines);
对于(int i=0;i

编辑:这里有一个演示:(没有windows控件,因为ideone不支持它)

我知道了如何将多行文本框放入列表,将删除的字符串放入列表,但不确定如何删除。解决问题的简单方法是使用C#has现成的解决方案来解决几乎任何基本问题。你应该花点时间读一本C#book.做得很好,Tim。非常感谢!