By using trim() we can remove white space characters from the beginning and end of a string.But to remove white space characters in middle we cannot use trim() method.
we can easily remove the white spaces/empty space in a string by replace method
string strSample = “Test with white space”;
strSample = strSample.Replace(” “, “”);
Result : strSample = “Testwithwhitespace”