Skip to the content.

Use the following extension method to remove the extra spaces ( in the middle ) from a desired string , its easy right :)

public static string RemoveWhiteSpace(this string mStr)
{
    string mRet = mStr.Trim().Replace("  ", " ");
    while (mRet.Contains("  "))
      mRet = mRet.Replace("  ", " ");
 
    return mRet.Trim();
}