我需要在 C# 控制台应用程序的 app.config 文件中添加 html 标签。我试过了
<p>
但它对我有用。有任何想法吗?
最佳答案
首先,将对 System.Web
的引用添加到您的项目中。然后,您可以通过 HTML encoding 存储您的 HTML它。只需对存储在配置文件中的值调用 HttpUtility.UrlDecode()
。
你的配置文件:
<appSettings>
<add key="HTML" value="<p>My paragraph</p>"/>
</appSettings>
您的代码:
string html = HttpUtility.UrlDecode(ConfigurationManager.AppSettings["HTML"]);
关于c# - .net 控制台应用程序中 app.config 文件中的 html 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4858799/