C# 为什么我的标签会忽略App.config文件中的新行(“n”)?

C# 为什么我的标签会忽略App.config文件中的新行(“n”)?,c#,.net,winforms,C#,.net,Winforms,因此,我有一个App.config文件设置,如下所示: <configuration> <appSettings> <add key="Description" value="My too long of a\n description that needs\n new lines so the entire\n thing can be seen."/> </appSettings> </configurat

因此,我有一个App.config文件设置,如下所示:

<configuration>
    <appSettings>
        <add key="Description" value="My too long of a\n description that needs\n new lines so the entire\n thing can be seen."/>
    </appSettings>
</configuration>

我希望在Windows系统上使用
\r\n
(返回,换行符),而不仅仅是换行符。在任何情况下,App.config都是XML,因此您需要XML转义序列:

&#xD;&#xA;
如果您想将
“\n”
保留为xml格式(为了清晰起见?),那么一个简单的解决方案是:

myLabel.Text = ConfigurationManager.AppSettings["Description"].Replace("\\n","\xa\xd");

\n
在C#中将
\xa\xd
表示为字符串文字,但在该xaml中,它仍然只有2个字符。您的可能重复是对的,它是重复的。谢谢你指给我看@Sinatr这是一个关于App.config的问题,而不仅仅是XML。我反对将其作为副本关闭@Sinatr@Joe重复是语言不可知的问题,这正是你的建议。然后我想到了
string.Replace
。。。
myLabel.Text = ConfigurationManager.AppSettings["Description"].Replace("\\n","\xa\xd");