[英]No errors not working two nested for loops in C#
这个bugger不起作用,我什至无法检查出什么毛病,因为它不会达到断点。 如果在“ Console.WriteLine(“从未到达断点”);“处设置断点, 它不会触发中断。 这是简单的代码,但我不知道为什么它不起作用。 可能需要更多的睡眠:) ThisPixelCheck函数,如果在某个点发现颜色,则返回true或false。 但是看起来它不是代码所能达到的。
void FindPixel()
{
int x = 455;
int y = 1109;
int found = 0;
Color findcolor = ColorTranslator.FromHtml("#FFFFFF");
for (int yplus = 0; yplus > 50; yplus++)
{
for (int xplus = 0; xplus > 50; xplus++)
{
Console.WriteLine("breakpoint is never reached");
var point = new Point(x + xplus, y + yplus);
var foundpixel = ThisPixelCheck(point, findcolor);
if (foundpixel)
{
found += 1;
}
}
status_Label.Text = found.ToString() + " pixels found.";
}
}
void FindPixel()
{
int x = 455;
int y = 1109;
int found = 0;
Color findcolor = ColorTranslator.FromHtml("#FFFFFF");
for (int yplus = 0; yplus < 50; yplus++)
{
for (int xplus = 0; xplus < 50; xplus++)
{
Console.WriteLine("breakpoint is never reached");
var point = new Point(x + xplus, y + yplus);
var foundpixel = ThisPixelCheck(point, findcolor);
if (foundpixel)
{
found += 1;
}
}
status_Label.Text = found.ToString() + " pixels found.";
}
}
for
循环是错误的。
for (int yplus = 0; yplus > 50; yplus++)
该行yplus为零且小于50,因此程序永远不会进入循环。 你应该尝试yplus <50
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.