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?
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?
Sure, use the
Replace()
method.(And if you want people here to want to help you in the future, my recommendation would be to start accepting some answers. Just a thought.)
Did you try using the
Replace
method of thestring
object. This will do the trick:To replace # with text
To replace space with another character
Be sure to retrieve the returned string from the Replace() method as it won't change the original string...it generates a new one.