我有以下假设搜索数组的代码:
for (int i = 0; i < this.passwordList.Length; i++)
{
string userInput = Convert.ToString(this.passInput);
if(userInput == passwordList[i])
{
MessageBox.Show("FOUND");
foundResult = 1;
break;
}
//MessageBox.Show();
}
数组有以下结果:
public string[] passwordList = {"123456", "145784" , "asasas"};
我做错了什么!?!?
最佳答案
错误大概在这里:
string userInput = Convert.ToString(this.passInput);
如果您有 WinForms 控件,请尝试这样的操作:
string userInput = this.passInput.Text;
您可能还想在调试器中检查 userInput
的值,以确保它包含您期望的值。
关于c# - 搜索数组未返回任何结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8280758/