【发布时间】:2014-10-25 14:16:36
【问题描述】:
private void button1_Click(object sender, EventArgs e)
{
Random random = new Random();
int getal1 = random.Next(0, 100);
Random random2 = new Random();
int getal2 = random2.Next(0, 100);
int Antwoord = getal1 + getal2;
if (Antwoord == textBox1.Text);
...
}
它说
运算符“==”不能应用于“字符串”和“整数”类型的操作数
有人可以帮我吗?
【问题讨论】:
-
您需要学习 C# 的基础知识。即使是简单的教程,答案也会很清楚。
-
Antwoord是一个整数,而textBox1.Text是一个字符串。因此,您无法比较它们。您必须先将textBox1.Text转换为整数(反之亦然将Antwoord转换为字符串)。
标签: c#