我正在制作一个随机数字生成器,但无法使其工作。它说不能将int类型转换为System.Windows.Forms.Label无法将int类型转换为System.Windows.Forms.Label
private void button1_Click(object sender, EventArgs e)
{
Random r1 = new Random();
string a = Text1.Text
int b = int.Parse(a);
b++;
abc.Text = r1.Next(b).ToString();
}
}
}
改变了它。上面的代码现在是正确的。谢谢您的帮助!
当我编译它的文本属性,没有错误,但是当我尝试运行它时,它说该值不能为空,然后关闭该程序。 – user3024531
OP使用的'Random'构造函数没有任何问题。问题可能是'abc'为空。 –
找到了。它是分配给console.readline()的字符串; – user3024531