c# - 搜索数组未返回任何结果

标签 c# visual-studio

我有以下假设搜索数组的代码:

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/

相关文章:

c++ - 在链接之前修改 visual studio 生成的程序集

c++ - VS : How to configure DebugWithReleaseCRT?

c# - LINQ 中的双重过滤

c# - 第一次登录后 SSO Request.IsAuthenticated 始终为 false,但第一次 SSO 登录工作正常

c# - 在 asp.net 中结合代码绑定(bind) css 类和页面 css 类

visual-studio - 使用 Gulp 更新 ASP.NET CORE 2 中的 Bootstrap + SASS?

c++ - 为什么我无法在 Visual Studio 的调试监 window 口中查看 cout?

c# - ASP.NET 刷新 UpdatePanel OnClientClick

C#如何知道一个远程对象是否实现了一个接口(interface)

visual-studio - Visual Studio 中使用 FSharp 的相对目录路径