using System.Linq; ... string source = "abc def 789"; string result = string.Concat(source.Where(c => !char.IsWhiteSpace(c))); Console.WriteLine(result);