c# - 如何显示包含一些标签内容的 MessageBox 消息?

标签 c# winforms messagebox

我想让 messagebox.show 说(“对不起 - 你输了,号码是”,“label1.Text”);但在它说 label.text 的地方,我希望它说出生成的数字。

private void button1_Click(object sender, EventArgs e)
    {
        RandomNumber(0,99);
        button2.Enabled = true ;
        button1.Enabled = false;
        if (textBox1.Text == label1.Text)
            MessageBox.Show("Winner");
        if (textBox1.Text != label1.Text)
            MessageBox.Show("Sorry - You Lose, The number is{0}",label1.Text);            
    }

最佳答案

MessageBox.Show("Sorry - You Lose, The number is " + label1.Text);

关于c# - 如何显示包含一些标签内容的 MessageBox 消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4108146/

相关文章:

c# - 只允许特定字母到 DataGridView 单元格

c# - 消息框出现两次 C#

python - 在 python 中获取屏幕顶部的 tkinter Messagebox

c# - 在 VS 2017 中的预构建事件中使用 protoc 从 .proto 文件生成 c# 文件

c# - VS2015 代码覆盖率不适用于 ASP.NET Core 1.0(以前称为 ASP.NET 5)中的测试

c# - 启用 x 轴滚动以进行图表控制

c# - SendInput Ctrl + C 然后通过 Clipboard.GetText 检索复制的内容不起作用

c# - 在 ODATA $metadata 上设置命名空间

c# - 如何在可观察集合中设置值?

c# - Windows Phone 8.1 (Silverlight) 消息框扩展功能