C# Messagebox未显示完整内容

C# Messagebox未显示完整内容,c#,string,messagebox,C#,String,Messagebox,我使用以下代码通过MessageBox向我的应用程序用户提问: var site = Registry.GetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters", "DynamicSiteName", "Unconnected") as string; var selectedSite = (Options.GetUserSetting("Site", "Selecte

我使用以下代码通过
MessageBox
向我的应用程序用户提问:

var site = Registry.GetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters",
    "DynamicSiteName", "Unconnected") as string;
var selectedSite = (Options.GetUserSetting("Site", "SelectedSite"));

if () // Some checks go here
{
    DialogResult ret = MessageBox.Show(
        string.Format("The selected site is {0}. But you're in {1}...{2}Want to change it ?", selectedSite, site.Trim(), Environment.NewLine),
        "Stupid default selection...",
        MessageBoxButtons.YesNo,
        MessageBoxIcon.Question);
    // Some process goes here
}
将显示带有以下文本的
消息框

所选站点为[SelectedSiteNameGoeSher]。但你在[网站Goesher]

这有点令人不安,因为我不明白为什么字符串会被拆分

如果我将
站点
替换为硬编码字符串,则消息将正常显示

我怎样才能找回丢失的零件

编辑 以下是我的输出:

这是我想要的输出:


您已经获得了使用
Environment.NewLine
的格式设置。。你想发生什么?(对无效编辑表示歉意)无法在此处复制。什么是
site
selectedSite
?这里第二行显示了
要更改它吗?
。字符串中是否有特殊字符?首先将字符串输出到变量可能会有所帮助,以查看它有什么值,如果不知道确切的文本类型(即长度和任何特殊字符),很难复制该字符串如果您首先将站点设置为不包含
NUL
字符,则最好的位置是,您可以在执行messagebox之前尝试删除它,但这与正确设置字符串没有多大帮助