不能int类型转换为System.Windows.Forms.Label [英] cannot convert type int to System.Windows.Forms.Label
本文介绍了不能int类型转换为System.Windows.Forms.Label的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想提出一个随机数生成器,但我不能让它的工作。它说不能int类型转换为System.Windows.Forms.Label
I am making a random number generator but i cant get it to work. it says cannot convert type int to 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();
}
}
}
改变了它。上面的代码现在是正确的。感谢您的帮助!
changed it. code above is now correct. thanks for the help!
推荐答案
您的分配值,标签不标签的文本。此行
You are assigning the value to the label not the text of the label. This line
abc = r1.Next(b);
应
should be
abc.Text = r1.Next(b).ToString();
该错误是想告诉你,它不能将转换为 INT
对象转换为标签
对象
这篇关于不能int类型转换为System.Windows.Forms.Label的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文