【问题标题】:How to write new line character \n in resx file?如何在 resx 文件中写入换行符 \n?
【发布时间】:2019-11-06 12:32:31
【问题描述】:

如何在 resx 文件(例如 MyFile.resx)中写入换行符 \n?

示例:我有带有属性 MyMessage = "One line\nNextLine" 的 resx 文件

当我使用时: MessageBox.Show(MyFile.MyMessage)我在一行中有一条消息(没有回车)。

资源编辑器中的 Shift + Enter 不起作用。

【问题讨论】:

标签: c# .net resx


【解决方案1】:

如果您使用 Managed Resources Editor 打开 .resx 文件,您可以按 ShiftEnter 输入多行消息:

如果您使用文本编辑器打开 .resx 文件,相应的条目如下所示:

  <data name="MultiLineMessage" xml:space="preserve">
    <value>Test
Message</value>
  </data>

然后调用它

MessageBox.Show(Properties.Resources.MultiLineMessage);

返回此框:

所以,一切似乎都按预期进行。所以请重新检查您的资源文件中是否真的有多行消息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-08
    • 1970-01-01
    • 2012-08-27
    • 1970-01-01
    • 2018-10-02
    相关资源
    最近更新 更多