Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Putting a quotation mark within quotation marks?

Tags:

c#

I'm using String.Replace to replace certain characters. How do I replace the " sign with a different sign of my choice?

artikelBezeichnung = artikelBezeichnung.Replace(""", "!");

That doesn't seem to work

like image 689
AzulShiva Avatar asked Nov 28 '25 00:11

AzulShiva


2 Answers

Either:

artikelBezeichnung = artikelBezeichnung.Replace("\"", "!");

Or:

artikelBezeichnung = artikelBezeichnung.Replace(@"""", "!");
like image 136
Jcl Avatar answered Nov 30 '25 15:11

Jcl


Escaping isn't really necessary, since String.Replace has an overload that accepts a char:

artikelBezeichnung = artikelBezeichnung.Replace('"', '!');

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!