I'm making a program. Now to write the data in the file I need to replace the spaces in the string obtained with lets say a # symbol.
Is there any command in C# that lets me do this without looping through the whole string?
Did you try using the Replace method of the string object. This will do the trick:
string newString = oldString.Replace(" ", "#");