如果不做出任何决定?
看这个:
foreach(Object Item in comboBox1.Items)
{
if (Convert.ToString(Item) == Convert.ToString(dsGirasol.Tables["DatosGirasol"].Rows[contador][0]))
{
repetido = true;
break;
}
else
{
repetido = false;
}
}
请注意,两个可能的输出都有一个消息框。然而,当我运行这个时,什么也没有出现,其余的代码继续运行...
编辑:添加了周围的循环!
Look at this:
foreach(Object Item in comboBox1.Items)
{
if (Convert.ToString(Item) == Convert.ToString(dsGirasol.Tables["DatosGirasol"].Rows[contador][0]))
{
repetido = true;
break;
}
else
{
repetido = false;
}
}
Note that both of the possible outputs have a messagebox. However when I run this, nothing appears at all, and the rest of the code continues to run...
EDIT: Added the surrounding loop!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为什么你想要
break
在那里?试试这个:Why do you want the
break
there for? Try this:在评估相等性之前,尝试评估条件的左侧和右侧部分。
我只能想象它一定抛出了一个被默默捕获的异常。
这将帮助您调试问题。
例如:
编辑:
现在我看到您正在使用循环,回到基础知识,循环是否正在运行?
低技术调试,检查组合框中是否有一些项目,并且您正在引用您想要的组合:)
Try evaluating the left and right parts of the condition before you evaluate the equality.
I can only imagine that it must be throwing an exception that is silently caught.
This will help you debug the issue.
eg:
EDIT:
Now that I see you are using a loop, go back to basics, is the loop even running?
Low tech debugging, check that there are some Items in the combobox and that you are referencing the combo you intended :)
好吧,这很奇怪,我设法通过将每个循环放在一个单独的方法上来解决这个问题,现在它可以工作了,无论如何感谢您的帮助!
Ok this is strange, I managed to solve the problem by puting each loop on a separate method, and now it works, thanks for the help anyways!