The most common method used to remove white spaces from a string is Trim() function.
See the below example.
string name = " chamara janaka ";
Response.Write(name.Trim());
as you can see there are three white spaces in the original string at the start, end and in between. When you use Trim() it will only remove white space from the end and the start of the string.
so the out put will be
"chamara janaka"
You can use Replace() function to remove all white spaces.
Response.Write(name.Replace(" ", ""));
Output will be
"chamarajanaka"
No comments:
Write comments