简体   繁体   中英

Escape & character in string

我想设置值appconfig键,但值包含&character.I尝试双&&像这样的“8L && L26X0s8 @ P”但是不工作。可以帮助我吗?

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

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

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

have you tried &amp ? This is the usual escape

您可以使用Regex.Escape(字符串)转义任何字符

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM