How to simplify the whitespaces in .NET System.String
Kwiecień 20th, 2007 . by vipIf you’ve got ” some spaces here in string „, and want only single spaces, you can use System.Text.RegularExpressions space.
The only line would give you only one space instead of many.
[csharp]output = Regex.Replace(input, @”\s+”, ” „);[/csharp]
To remove spaces from the beggining and end, consider the String.Trim method.