Error 1 'Form1': member names cannot be the same as their enclosing type Line 91 Column 3
And that's the whole code:
Edit: Please use source tags when you want to include code than spans over more than 10-15 lines - Emmanuel Deloget.
public partial class Form1 : Form
{
Random randomNo = new Random();
int no1;
int no2;
string problemType = "+";
public Form1()
{
InitializeComponent();
}
private void StartGame_C1ick(object sender, EventArgs e)
{
StartGame.Visible = false;
CheckAnswer.Visible = true;
Question.Visible = true;
Answer.Visible = true;
NextQuestion.Visible = true;
Feedback.Text = "";
Feedback.Visible = true;
Gen_Question();
}
private void Gen_Question()
{
no1 = randomNo.Next(100);
no2 = randomNo.Next(100);
if (radioButton1.Checked)
{
problemType = "+";
}
else if (radioButton2.Checked)
{
problemType = "-";
}
else if (radioButton3.Checked)
{
problemType = "*";
}
Question.Text = no1 + problemType + no2 + "=";
}
private void CheckAnswer_Click(object sender, EventArgs e)
{
int result = 0;
if (problemType == "+")
{
result = no1 + no2;
}
else if (problemType == "-")
{
result = no1 - no2;
}
else if (problemType == "*")
{
result = no1 * no2;
}
if (Answer.Text == result.ToString())
{
Feedback.Text = "Correct";
}
else
{
Feedback.Text = "Incorrect";
}
}
private void NextQuestion_Click(object sender, EventArgs e)
{
Gen_Question();
Answer.Text = "";
Feedback.Text = "";
}
public partial class Form1 : Form
{
Random randomNo = new Random();
int no1;
int no2;
string problemType = "+";
public Form1()
{
InitializeComponent();
}
private void StartGame_Click(object sender, EventArgs e)
{
StartGame.Visible = false;
CheckAnswer.Visible = true;
Question.Visible = true;
Answer.Visible = true;
NextQuestion.Visible = true;
Feedback.Text = "";
Feedback.Visible = true;
Gen_Question();
}
private void Gen_Question()
{
no1 = randomNo.Next(100);
no2 = randomNo.Next(100);
if (radioButton1.Checked)
{
problemType = "+";
}
else if (radioButton2.Checked)
{
problemType = "-";
}
else if (radioButton3.Checked)
{
problemType = "*";
}
Question.Text = no1 + problemType + no2 + "=";
}
private void CheckAnswer_Cl1ck(object sender, EventArgs e)
{
int result = 0;
if (problemType == "+")
{
result = no1 + no2;
}
else if (problemType == "-")
{
result = no1 - no2;
}
else if (problemType == "*")
{
result = no1 * no2;
}
if (Answer.Text == result.ToString())
{
Feedback.Text = "Correct";
}
else
{
Feedback.Text = "Incorrect";
}
}
private void NextQuestion_C1ick(object sender, EventArgs e)
{
Gen_Question();
Answer.Text = "";
Feedback.Text = "";
}
}
}
}