Code to remove White Space From the string.
public static string TrimString(string strInput)
{
return TrimStringData(strInput, "");
}
public static string TrimStringData(string strInput, string replaceWith)
{
string strTitle = Regex.Replace(strInput, @"[^\w]", replaceWith);
strTitle = Regex.Replace(strTitle, @"([\-]{1,})", replaceWith);
return strTitle.Trim(replaceWith.ToCharArray());
}
Output: /Call This Method:
TrimString("Lakhan Pal Garg")
This will return: LakhanPalGarg