2013-04-10 83 views
-1

我要全部更换”和”从字符串全部替换“和“从字符串

如串

"23423dfd 
"'43535fdgd 
""'4353fg 
""'''3453ere 

结果应该是

23423dfd 
43535fdgd 
4353fg 
3453ere 

我想这myString.Replace("'",string.Empty).Replace('"',string.Empty);但它没有给我正确的结果。

+4

你尝试[与string.replace(http://msdn.microsoft。 com/en-us/library/system.string.replace.aspx)? – Habib 2013-04-10 12:35:40

+0

@Habib:是的,我尝试过,“\”就是我想要的 – 2013-04-10 12:38:16

+0

你应该发布你尝试过的东西,以及你在哪里被困在 – Habib 2013-04-10 12:38:58

回答

3

使用String.Replace

mystring = mystring.Replace("\"", string.Empty).Replace("'", string.Empty) 
1

做两个替代对象:

s = s.Replace("'", "").Replace("\"", ""); 
1

试试这个:

string s = yoursting.Replace("\"", string.Empty).Replace("'", string.Empty);