Here is a very handy extension method to remove white spaces from strings.
1 public static string RemoveWhiteSpace(this string TextToRemoveWhiteSpaces)
2 {
3 string pattern = "\\s+";
4 string replacement = " ";
5 string result = Regex.Replace(TextToRemoveWhiteSpaces, pattern, replacement);
6 return result;
7 }
Adapted from http://msdn.microsoft.com/en-us/library/xwewhkd1.aspx
Happy coding.