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

Far*_*med 0 c# string c#-4.0

我有一些字符串,其中一些xml驻留.

字符串是:

string xmlRead = "<ns0:RequestedAmount xmlns:ns0=\"http://tempuri.org/XMLSchema.xsd\">  <ns0:RequestedAmount></ns0:RequestedAmount>  </ns0:RequestedAmount>" +
                         "<ns0:Response xmlns:ns0=\"http://tempuri.org/XMLSchema.xsd\">  <ns0:Response/> </ns0:Response>" +
                         "<ns0:isValid xmlns:ns0=\"http://tempuri.org/XMLSchema.xsd\">  <ns0:isValid/> </ns0:isValid>";
Run Code Online (Sandbox Code Playgroud)

我试过这个:

string s=xmlRead.Replace(@"\","");
string s=xmlRead.Replace("\"","");
string s=xmlRead.Replace(@"\",string.Empty);
Run Code Online (Sandbox Code Playgroud)

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

DGi*_*bbs 7

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

MSDN转义序列

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