I have a variable test..
String test = TextBox1.Text;
I want to know if the user enters into this variable 04151.
I have a variable test..
String test = TextBox1.Text;
I want to know if the user enters into this variable 04151.
if (test == "04151")
{
MessageBox.Show("Yep!");
}
if (test.Contains("04151"))
{
MessageBox.Show("Yep!");
}
test.Contains("04151")if( test == "04151" )
{
//04151 was entered
}
?
If this is some type of checking a password, I would strongly urge you to do it in a safer way than checking towards a hard coded string inside your app. There are many issues with that approach. For one, you will have to recompile your program to alter your password.
public bool Matches(string test)
{
return String.Compare(test, "04151", true) == 0;
}