c# - 如何在resx文件中写入换行符\n?

标签 c# .net resx

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

示例:我有一个带有属性 MyMessage = "One line\nNextLine"

的 resx 文件

当我使用时: MessageBox.Show(MyFile.MyMessage) 我在一行中收到一条消息(无需 Enter)。

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

最佳答案

如果您使用托管资源编辑器打开 .resx 文件,您可以按 ShiftEnter 输入多行消息:

Multiline text in resource editor

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

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

enter image description here

并调用它

MessageBox.Show(Properties.Resources.MultiLineMessage);

返回此框:

Messagebox with multiline message

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

关于c# - 如何在resx文件中写入换行符\n?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58730263/

相关文章:

c# - Firefox 不显示动态添加的 Silverlight 5 控件

c# - 试图检查一个点是否在线的误差范围

.net - 在 .net 中打开/写入文件时读取?

更改命名空间后 C# resx 文件不工作

visual-studio-2010 - "Run Custom Tool"用于 MVC2 项目中的 resx 文件(来自外部应用程序/脚本)

C# WPF 将本地化文本绑定(bind)到元素

c# - 如何检查分配了哪个事件?

c# - 将 Azure Function 项目添加到解决方案后,一些tasks.json 文件设置已被删除

c# - 如何检查两个列表是否具有相同的值并从其中一个列表中删除值

c# - Telegram C# 示例发送消息