trim whitespaces from a c# colection code example Example: remove whitespace between string c# string str = "C Sharp"; str = Regex.Replace(str, @"\s", "");