Replace control character in string c#
c#, hex, string
Solution
Strings are immutable - you need to reassign:
text = text.Replace('\x2', ' ');
Problem
Some text fields in my database have bad control characters embedded. I only noticed this when trying to serialize an object and get an xml error on char `` and ``. There are probably others. How do I replace them using C#? I thought something like this would work: ``` text.Replace('\x2', ' '); ``` but it doesn't. Any help appreciated.