-1

I am trying to replace ' with " but to no avail.

I have tried the following:

output = output.Replace(@"'", @""");

output = output.Replace("'", @""");

output = output.Replace(@"'", """);

output = output.Replace(@"'", """");
Rishit Dagli
  • 1,000
  • 8
  • 20
gymcode
  • 4,431
  • 15
  • 72
  • 128
  • Note that if this is going to be applied to code (e.g. Javascript or Python) then char-per-char replacement will run into problems if the code itself contains escaped quotes or double quotes. To do a proper substitution in that case you need something more sophisticated (for example a regular expression). – 6502 May 03 '20 at 06:36
  • Use the debugger's text visualizer feature, click on the spy glass. – Hans Passant May 03 '20 at 08:35
  • Duplicate of [Escape double quotes in string](https://stackoverflow.com/questions/14480724/escape-double-quotes-in-string) – Herohtar May 03 '20 at 08:41

2 Answers2

1

You could use this piece of code, I have added a \

out = out.Replace("'","\"");

Rishit Dagli
  • 1,000
  • 8
  • 20
0
output = output.Replace("'", "\"");
jscarle
  • 1,045
  • 9
  • 17
  • Thank you for your suggestion. I tried it and it include the backslash character as well – gymcode May 03 '20 at 06:38
  • Then you're not using the proper characters, look at the fiddle: https://dotnetfiddle.net/1pLasS – jscarle May 03 '20 at 06:42
  • this is so weird, I copied my code in the fiddle and the backslash \ doesn't show up, but it did in my code. hmmm – gymcode May 03 '20 at 06:48