Escape & character in string

杀马特。学长 韩版系。学妹 提交于 2019-12-14 01:23:23

问题


I want to set value appconfig key,but value contains & character.I tried double && like this "8L&&L26X0s8@P" but dont working.Can you help me please?

 <add key="SAP_PASS" value="8L&L26X0s8@P"/>

回答1:


As app.config is xml file, use XML entities for this.

Specifically & is coded as &amp; (including the semicolon) in XML.




回答2:


have you tried &amp ? This is the usual escape




回答3:


You can escape any character using Regex.Escape(string)



来源:https://stackoverflow.com/questions/35061018/escape-character-in-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!