Hi, I'm new to C# and trying to program myself a number guessing game. I've got a troubling problem with data type formats..
Here is my code
private void btnOk_Click(object sender, EventArgs e)
{
String invalue;
int guessedNumber;
int secretNumber = RandomNumber(1, 100);
do
{
invalue = textBox1.Text;
guessedNumber = int.Parse(invalue); --- I got an error here
if (guessedNumber == secretNumber)
{
MessageBox.Show("Correct guess!");
}
else if (guessedNumber < secretNumber)
{
MessageBox.Show("Higher than that!");
textBox1.Clear();
}
else if (guessedNumber > secretNumber)
{
MessageBox.Show("Lower than that!");
textBox1.Clear();
}
} while (guessedNumber != secretNumber);
}
Any help would be appreciated much.. thank you