-3
var txt = "\"";
txt = txt.Replace("\"", """);
Console.WriteLine(txt);

output: "

need: "

Is it possible to get the desired result?

  • This code does not give that output. Read [ask] and provide a [mre]. Are you using ASP.NET WebForms and a Label, for example? – CodeCaster Jan 05 '21 at 13:28
  • Does this answer your question? [C# string replace does not actually replace the value in the string](https://stackoverflow.com/questions/13277667/c-sharp-string-replace-does-not-actually-replace-the-value-in-the-string) – Drag and Drop Jan 05 '21 at 14:00
  • and [string.Replace (or other string modification) not working](https://stackoverflow.com/questions/1948978/string-replace-or-other-string-modification-not-working) – Drag and Drop Jan 05 '21 at 14:00

1 Answers1

3

Try this:

var txt = "\"";
txt = txt.Replace("\"", """);
Console.WriteLine(txt);

And check the documentation:

https://learn.microsoft.com/en-us/dotnet/api/system.string.replace?view=net-5.0

Kapitany
  • 1,319
  • 1
  • 6
  • 10