.net - AppConfig键值对

标签 .net

在我的应用程序中,需要从字符串中删除特殊字符。我可以通过从config appsettinf键值对中读取一串特殊字符来实现此目的。

前任 :

<appSettings>
<add key="ExcludeSpecialChars" value ="%'^"/>
</appSettings>

当我在值中包含&时,我遇到了问题
前任 :
key="ExcludeSpecialChars" value ="&%'^"

应用程序无法构建,并显示错误“无法解析实体”。

有什么解决方法可以让我在特殊字符字符串中包含&吗?

最佳答案

由于.NET .config文件是XML,因此请使用entity &amp;来表示“&”号:

<appSettings>
    <add key="ExcludeSpecialChars" value ="&amp;%'^"/>
</appSettings>

关于.net - AppConfig键值对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8089426/

相关文章:

c# - 使用编译时编织的依赖注入(inject)?

c# - 对可能未打开或关闭的 SqlConnection 调用 Close

.net - 给 VSTO 开发人员的提示

c# - 使用 TreeNode 作为用户设置

c# - Roslyn 代码分析器——什么时候应该使用 "this."?

asp.net - 我可以将我的 ASP.NET 应用程序迁移到云端吗?

.net - ProvidersHelper.InstantiateProviders 的替代方案

.net - 为什么存在String.Format重载?

c# - DataTable内部索引已损坏

.net - 调用 Assembly.GetTypes() 时如何防止 ReflectionTypeLoadException