I'm doing a C sharp homework which is due tomorrow and I can't seem to get things right. Please help!
CODE
private void button1_Click(object sender, EventArgs e)
{
string userInput;
userInput = this.textBox1.Text;
if (userInput.Contains("$"))
{
this.lblOutput.Text = "Thank you";
this.lblOutput.ForeColor = Color.Green;
}
else
{
this.lblOutput.Text = "Error";
this.lblOutput.ForeColor = Color.Red;
}
}
This code is embedded in a button in the form I made. This code means that if "$" is entered in the text box when the button is pressed, it will display the message "Thank You". Otherwise, it will say "Error".
Now what I need to do is to change the code so "Thank You" will be displayed when a character between 0-9 is entered. Can anyone help me?
I would appreciate the help! Also, if you got a very reliable source for learning C# and stuff, please give them to me.
CODE
private void button1_Click(object sender, EventArgs e)
{
string userInput;
userInput = this.textBox1.Text;
if (userInput.Contains("$"))
{
this.lblOutput.Text = "Thank you";
this.lblOutput.ForeColor = Color.Green;
}
else
{
this.lblOutput.Text = "Error";
this.lblOutput.ForeColor = Color.Red;
}
}
This code is embedded in a button in the form I made. This code means that if "$" is entered in the text box when the button is pressed, it will display the message "Thank You". Otherwise, it will say "Error".
Now what I need to do is to change the code so "Thank You" will be displayed when a character between 0-9 is entered. Can anyone help me?
I would appreciate the help! Also, if you got a very reliable source for learning C# and stuff, please give them to me.