Use
below method to remove empty spaces:
public static string RemoveEmptySpace(string inputString)
{
string ouputString = string.Empty;
if (!string.IsNullOrEmpty(inputString))
{
ouputString = Regex.Replace(inputString,
"\\s+", " ");
ouputString = Regex.Replace(ouputString,
"^\\s+|\\s+$", "");
}
return ouputString;
}