启用 XML 自动格式化时如何在字符串设置中存储空格?

发布于 2024-10-03 09:16:50 字数 499 浏览 1 评论 0原文

使用 Visual Studio 生成的设置文件,当我仅输入空格时,它们会转换为换行符。

我认为这是因为设置文件内容已同步到 app.config,并且由于 IDE 启用了 XML 自动格式设置,因此它会

<setting name="Separator" serializeAs="String">
    <value> </value>
</setting>

转换为

<setting name="Separator" serializeAs="String">
    <value>
    </value>
</setting>

自动

: 。如何在不禁用 XML 自动格式化的情况下解决此问题?

我尝试了 &nbsp; 但没有成功。

Using Visual Studio generated Settings file, when I input only spaces they are converted to a line break.

I think that's because the Settings file content is synchronized to app.config and as the IDE has XML auto formatting enabled it converts:

<setting name="Separator" serializeAs="String">
    <value> </value>
</setting>

to

<setting name="Separator" serializeAs="String">
    <value>
    </value>
</setting>

automatically.

How to fix this without disabling XML auto formatting?

I tried   without success.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

亣腦蒛氧 2024-10-10 09:16:50

确实很奇怪。
我唯一发现的是:创建设置,编辑app.config文件: (这是非括号空格的xml)打开设置文件,它会警告它正在更改值,按确定。但是,在代码中使用时的设置将以字符串形式给出 所以,这不是一个完整的答案......

Marcel

It is strange indeed.
The only thing I found is: create the setting, edit the app.config file: <Value> </Value> (which is xml for non bracking space) Open the settings file, it will warn that it is changing the value, press ok. But, the setting when used in code will give as string So, not a complete answer...

Marcel

素罗衫 2024-10-10 09:16:50

您可以手动编辑 app.config 文件以删除标签之间的 CR/LF 字符。然而,我的测试(在 VS2008 中)总是导致每当您在 VS 中打开项目的属性窗口时都会重新插入 CR/LF 字符。

也许最好的解决方案是使用 VS 使用的标准项目设置之外的自定义设置文件。

You can edit the app.config file manually to remove the CR/LF characters in between the tags. However, my tests (in VS2008) always resulted in the CR/LF characters being reinserted anytime you open the properties window for the project in VS.

Perhaps the best solution is to use a custom settings file that lives outside of the standard project settings used by VS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文