从字符串C#中删除反斜杠

我有一些xml所在的字符串。

字符串是:

string xmlRead = "  " + "  " + "  "; 

我试过这个:

 string s=xmlRead.Replace(@"\",""); string s=xmlRead.Replace("\"",""); string s=xmlRead.Replace(@"\",string.Empty); 

什么都没有帮助我帮助我在这里做错了什么。

那些反斜杠实际上不会出现在最后的字符串中。 它们只是引号""转义序列。

MSDN转义序列

我的猜测是你在调试器中查看字符串,它仍然会显示为未转义。

使用以下代码可以帮助您。

  string x=@"ABCD\EFG"; string y=x.Replace(@"\","");