How can I replace a character in a string with something else?
问题 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? 回答1: Sure, use the Replace() method. s = s.Replace(" ", "#"); (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.) 回答2: To replace # with text string s = "test # again"; s = s.Replace("