从字符串 C# 中删除反斜杠 [英] Remove backslash from the string C#
本文介绍了从字符串 C# 中删除反斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些 xml 所在的字符串.
I have string in which some xml resides.
字符串是:
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>";
我已经试过了:
string s=xmlRead.Replace(@"","");
string s=xmlRead.Replace(""","");
string s=xmlRead.Replace(@"",string.Empty);
没有任何工作可以帮助我解决我在这里做错了什么.
Nothing is working kindly help me out what I am doing wrong here.
推荐答案
那些反斜杠实际上不会出现在最终字符串中.它们只是引号 ""
的转义序列.
Those backslashes won't actually appear in the final string. They are just escape sequences for the quotes ""
.
我的猜测是您正在调试器中查看字符串,但仍会将它们显示为未转义.
My guess is that you're viewing the string in the debugger which will still show them as unescaped.
这篇关于从字符串 C# 中删除反斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文