Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace character " in C#

Tags:

c#

I'd like to replace the character " by a space in a string in C#. But I have an issue when writing the function :

myString.Replace("""," ")

The first argument seems to be an issue. Any idea

like image 560
fabco63 Avatar asked Apr 16 '12 13:04

fabco63


3 Answers

Escape it:

myString.Replace("\""," ")
like image 137
user703016 Avatar answered Oct 20 '22 09:10

user703016


Use the overload that accepts chars instead of strings

myString.Replace('"', ' ');
like image 39
Steve Avatar answered Oct 20 '22 09:10

Steve


You need to escape the character by putting \ before it:

myString=myString.Replace("\""," ");

or user this:

 myString=myString.Replace('"',' ');
like image 32
Zaheer Ahmed Avatar answered Oct 20 '22 09:10

Zaheer Ahmed