Why is this "if" condition evaluating to "false"? [closed]

1 week ago 14
ARTICLE AD BOX

Why is my program returning "Code is invalid" when i have set entered a valid code and have set my form1 background to Color.Green?

private void checkNumber_Click(object sender, EventArgs e) { string userInput = correctNumber.Text; if (userInput == Form1.num && BackColor == Color.Green) { MessageBox.Show("Code is valid"); } else { MessageBox.Show("Code is invalid"); } }

David's user avatar

David

221k43 gold badges249 silver badges340 bronze badges

dawix's user avatar

New contributor

dawix is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

7

Read Entire Article