【发布时间】:2013-12-02 04:14:38
【问题描述】:
我正在尝试遍历字符串数组并检查/替换输入字符串中是否存在任何字符串。使用 LINQ,这就是我目前所拥有的。
string input = "/main/dev.website.com"
string[] itemsToIgnore = { "dev.", "qa.", "/main/" };
string website = itemsToIgnore
.Select(x =>
{ x = input.Replace(x, ""); return x; })
.FirstOrDefault();
当我运行它时,实际上什么都没有发生并且我的输入字符串保持不变?
【问题讨论】: