I have a list like so:
List<string> _unWantedWords = new List<string> { "word1", "word2", "word3" };
And I have a string like so:
string input = "word1mdjw ksjcword2 d word3fjwu";
I would like to remove the unwanted words in the input string, but strings are immutable in C#, so I though I would do something fancy in one swoop with a lambda expression. Like this:
string output = _unWantedWords.Select(x => input.Replace(x, ""));
But I can't seem to get it to work, any ideas? :)
Daniel
StringBuilder.Replaceinstead ofString.Replace. It doesn't through off garbage like string manipulation does