随机数值应该打印到名为' number'的标签上。 - Visual C#
private void button1_Click(object sender, EventArgs e)
{
Random random = new Random();
int randomNumber = random.Next(0, 100);
number.Text = randomNumber();
}
答案 0 :(得分:1)
只需分配值,不要像函数一样使用它
int randomNumber = random.Next(0, 100);
number.Text = randomNumber.ToString() ;
答案 1 :(得分:-1)
Random random = new Random();
private void button1_Click(object sender, EventArgs e)
{
int randomNumber = random.Next(0, 100);
number.Text = randomNumber();
}