Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# String.Replace not finding / replacing Symbol (™, ®)

Tags:

c#

Basically what I'm trying to do is replace a symbol like ™, ® etc with something else but when I call

myString = myString.Replace("®", "something else")

Its doesn't do anything

Any Ideas?

like image 831
bigamil Avatar asked Aug 24 '11 16:08

bigamil


2 Answers

try myString.Replace("\u00A9", "else"); you have to escape the ©

like image 171
killie01 Avatar answered Sep 24 '22 10:09

killie01


When you use String.Replace you create a new string. It is a very common mistake to believe the the supplied string is modified. However, strings in .NET are immutable and cannot be modified.

You have to call it like this:

myString = myString.Replace("®", "something else");
like image 33
Martin Liversage Avatar answered Sep 23 '22 10:09

Martin Liversage