【发布时间】:2022-11-12 19:43:00
【问题描述】:
首先,我定义了我的字符串数组和一个要从中删除单词的字符串:
string[] excludeWords = {"word1","word2","word3","word4","word5"}
string sentence = "word1 word2 word5";
TextBox1.Text = sentence;
我想从句子中删除 excludeWords 所以我想在我的文本框中输出这个:
word3 word4
我尝试了 except 方法,但没有删除单词:
string filteredText = sentence.Except(excludeWords);
TextBox1.Text = filteredText
我应该使用什么方法?
【问题讨论】:
标签: c# asp.net asp.net-mvc asp.net-mvc-3