How to remove white spaces in asp.net?

user1225988 picture user1225988 · Feb 24, 2012 · Viewed 8.3k times · Source

I am retrieving data from a DB table using SqlDataReader in ASP.net. I append the retrieved data in a string builder and after that, dump the contents of the string builder into a text file. My problem is that in that text file white spaces are showing up between one column and another ... How can I remove the excess white spaces from my text file?

Thanks in advance.

Answer

thevan picture thevan · Feb 24, 2012
1. Text.Trim();
2. Text.Replace(" ", string.empty);