【发布时间】:2017-04-26 05:54:56
【问题描述】:
如何用特定单词“x”替换字符串中列表中的不同单词:
string str = "how to replace different words from list found in string with specific word";
var valueList = new List<string> { "replace", "string", "specific", "found", "how", "word"};
if (valueList.Any(str.Contains))
{
//...
}
如果使用 if 语句,我可以一一做到 str.Replace("replace", "x"); 等,但不确定如何从列出的值中正确获得相同的结果:
x 到 x 与 x x 的列表 x 中的 x 不同的单词
【问题讨论】: