How can I replace multiple spaces in a string with only one space in C#?
Example:
1 2 3 4 5
would be:
You can simply do this in one line solution!
string s = "welcome to london"; s.Replace(" ", "()").Replace(")(", "").Replace("()", " ");
You can choose other brackets (or even other characters) if you like.