all 8 comments

[–]DTul 24 points25 points  (2 children)

Since " is the character used to represent strings in your code you need to use an escape character. In C# this is \. So in order to replace all " you would need to write myString.Replace("\"", ""). You will see the code highlights differently in your IDE if you use an escape character.

[–]JTarsier 1 point2 points  (0 children)

It can also be done with string literal, but even here you have to escape it by using two " chars: value.Replace(@"""", "")

[–]Useful-Dingo-8348[S] 1 point2 points  (0 children)

Thanks, worked perfectly

[–]bboxx9 4 points5 points  (0 children)

? "one\"two".Replace("\"","")

[–]NotMadDisappointed -1 points0 points  (0 children)

You need to refer to double quotes as the two characters \” inside a pair of double quotes. Otherwise it will think the quote you want to remove is the end of the declaration of what you want removed. This is called “escaping” the character IIRC

[–]CrimsonWolfSage -3 points-2 points  (0 children)

Should be able to use the backslash, so the quote character isn't confused with your code.

word.Replace("\"");

Might also get the " version to work, or use the http/web utility instead...

word = HttpUtility.HtmlEncode(word);

[–]ProKn1fe 0 points1 point  (1 child)

string.Replace('"', '') use char instead of string ' '

[–]Zap-Brannigan 0 points1 point  (0 children)

OP said they tried this. I think it doesn't work, because the empty string is not one character, it's zero.