我想让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);